SUNY Geneseo Department of Computer Science


Induction and Recursion, Part 2

{Date}

CSci 141, Fall 2003
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Misc

I'm out of town Friday (Oct. 3)

Hand out Homework 1

Questions?

halfWayBack algorithm

    if okToMove()
        move()
        wallAndBack()
        move()
        move()
    else
        turn around

Induction Examples

Prove that this algorithm determines whether natural number n is odd or even:

    isOdd( n )
        if ( n == 0 )
            return false
        else if ( n == 1 )
            return true
        else 
            return isOdd( n - 2 )

Mini-assignment

One base case or two?

Induction? Works for k-1 >= 1?

Next

Techniques for counting operations in recursive algorithms

Read Section 7.2.1


Next Lecture