Comp 271-400 Week 3
Crown 103, 4:15-8:15
Bailey chapter 5, on recursion
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)
Class both.java in linkedlistij.zip: change from ArrayList to LinkedList.
Table of Factors
This is the example on Bailey page 88. Let us construct a table of all the
k<=n and a list of all the factors (prime or not) of k, and ask how much
space is needed. This turns out to
be n log n. The running time to construct the table varies with how clever
the algorithm is, it can be O(n2) [check all i<k for
divisibility], O(n3/2) [check all i<sqrt(k)], or O(n log n)
[Sieve of Eratosthenes].
Finding a space character in a string
The running time depends on whether we're concerned with the worst case
or the average case (we are almost never interested in the best case). If
the average case, then the answer typically depends on the probability
distribution of the data. If the text consists of English words separated
by spaces, then in most cases we'll find a space in <=10 steps, as most
English words are <= 10 characters long.
in-class lab: GetHashCode() values of strings from hashij.zip's
classes hashCodes.java and hashStats.java.
Chapter 6: Sorting
Recursion starts at Bailey page 94
Go through factorial in detail
- Why is recursive Fibonacci so slow?
- Why does recursive Fibonacci always return a value?
Postage (currently first-class is 49¢, and post cards are 34¢)
in-class lab 2
insertion and search