Comp 271-400 Week 4
Lewis Tower 410, 4:15-8:15 Nov 13
Welcome
Readings:
Bailey chapter 6, on sorting
Bailey chapter 9, on lists (and, in particular, linked
lists)
Bailey chapter 15.4.2: (chained) hashing
Morin chapter 1, sections 1.1 and 1.2
One slight peculiarity of Morin is
that he refers to the array-based List implementation of chapter 2 as an
ArrayStack.
Primary text: Bailey, online, and maybe Morin, also online.
Information about MSDNAA is in the Intro to C++
section
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/SortTester.java
Radix Sort
133 312
121 213 122
211 321 132 223
332
Naive approach: bucketize on the first digit, then sort the buckets
recursively.
1337 approach: bucketize on the last digit, concatenate, bucketize on
second-to-last digit, concatenate, bucketize on the first digit
(third-to-last digit)
Trees
binary trees
insertion and search
Lab 4: tree-based dictionary
insertion code
Recursion
Recursion starts at Bailey page 94
See recursion.html
and recursion1ij.zip.
- Expressions
- Assignment
- Framework: parsing statements plus syntax-directed actions.
- Exponentiation?
Trees
traversal
tree-based dictionaries