Comp 271-400 Week 4

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.




repl.it for C++

1. Speeding up slooow Fibonnaci recursion with an answer_cache

    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
    }


2. Stampchange with an answer_cache

3. expressions


4. TList (in demos)
    downcasting


Hashing

Lab 4

Example of a hash dictionary


Chapter 6: Sorting


Radix sort


Trees

binary trees
insertion and search
traversal
tree-based dictionaries