Comp 271-400 Week 4
Cuneo 311, 4:15-8:15
Bailey chapter 5 section 2 on recursion
Bailey chapter 3, on a Vector class
Bailey chapter 6, on sorting.
Bailey chapter 9 section 4 on Singly Linked Lists
Bailey chapter 15, section 4, on Hash Tables.
Morin 3.1: Singly Linked Lists
Morin 5.1: Chained Hash Table
Morin Chapter 11: sorting (Merge-sort and Quicksort only)
Primary text: Bailey, online, and maybe Morin, also online.
Exam next week
We will start the exam around 6:20. You'll have (almost) two hours, but
you shouldn't need all that time.
The study guide is on Sakai. Answers will be posted at the end of this
You can bring up to three pages (sides) of your own printed
or handwritten notes. You will also receive a copy of StrList.java, which
includes examples of basic Java constructions.
There's an algorithmic reason why quicksort's speed is affected by whether
the data is already sorted: if we pick data[left] as the pivot in a sorted
array, we'll partition into an empty left half and a right half of size N-1.
But why should mergesort be faster if the data is already sorted?
The algorithm executes exactly the same steps!
Demo: pldsorting/DualMerge.java, prev/sortspeed
Related question: why is insertion sort faster than selection sort?
121 213 122
211 321 132 223
Naive approach: bucketize on the first digit, then sort the buckets
1337 approach: bucketize on the last digit, concatenate, bucketize on
second-to-last digit, concatenate, bucketize on the first digit
in-class lab 1
insertion and search
Recursion starts at Bailey page 94
- Framework: parsing statements plus syntax-directed actions.