SUNY Geneseo Department of Computer Science


Introduction to Induction

Thursday, February 7

CSci 242, Spring 2013
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture

Questions?

Induction

Main technique for proofs about recursion, e.g., divide-and-conquer

kth smallest element in an unsorted array A[1..n]

        kthSmallest( A, first, last, k )
            if last < first
                // array section is empty, error!
            else
                p = partition( A, first, last )     // as in Quicksort
                if k < p-first+1
                    kthSmallest( A, first, p-1, k )
                else if k > p-first+1
                    kthSmallest( A, p+1, last, k+p )
                else
                    return A[p]

Hand out induction problem set

Next

More induction

No reading!


Next Lecture