Comp 271-400 Week 3
Lewis Tower 415, 4:15-8:15
Welcome
Readings:
Bailey chapter 6, sorting: selection sort, insertion
sort, mergesort, quicksort.
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.
Linked List
See lists.html#linked
and linkedlist.zip.
Class both.java in linkedlist.zip: change from ArrayList to LinkedList.
Hashing
Hashing: lists.html#hashing
in-class lab: GetHashCode() values of strings from hash.zip's
classes hashCodes.java and hashStats.java.
Chapter 6: Sorting
Mergesort, Quicksort
See sorting.html#sorting
Recursion
See recursion.html and recursion1.zip.
- Factorial (just started)
- Fibonacci
- Induction
- Postage (currently first-class is 49¢, and post cards are 34¢)
- Expressions.
in-class lab 1
Answer-cache implementation of Fibonacci(n), in recursion1.zip.
public static long
rfibonacci(int N) {
if (N<=1) return 1;
if rfibonacci(N) is in the answer
cache, return answer_cache[N]
return rfibonacci1(N-2) +
rfibonacci1(N-1); // but put result
into answer_cache[N] first
}
in-class lab 2
Get expr_assign.cs
(with oneline_tokenizer.cs)
to run
Both files together are in expr_assign_all.cs