SUNY Geneseo Department of Computer Science


Introduction to Induction

{Date}

CSci 141, Spring 2004
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Misc

CS Department conversation re recent swastika vandalism

Questions?

Induction step corresponds to what in algorithms?

Recursion and Correctness

Mini-assignment: Print an unbalanced string of parentheses, n "(" followed by 2n ")"

    void unbalancedParens( int n ) {
        if ( n > 0 ) {
            print "("
            unbalancedParens( n-1 )
            print ")"
            print ")"
        }
    }

Read Section 7.1.1

Mathematical Induction Example

Issue that shows up as a limiting factor in how efficiently a lot of computations can be done:

Prove the basic mathematical limit -- that every set of n items has 2n possible subsets.

[A 2-element Subset from a 3-Element Set]

Induction on the size of the set = n

Base case: empty set, i.e., { }, n = 0

Induction step:

[2^k Subsets Pair with Additional Element in 2 Ways]

Playact the proof:

Applying Induction to Algorithms

Unbalanced parentheses, n "(" followed by 2n ")"

Read Section 7.1.2


Next Lecture