University of Virginia, Department of Computer Science
CS200: Computer Science, Spring 2003

Notes: Friday 24 January 2003
Schedule

GEB Reading Guide
As you read GEB Little Harmonic Labyrinth and Chapter 5, here are some things to think about:

Defining Recursive Procedures
  1. Be optimistic.
    • Assume you can solve it.
    • If you could, how would you solve a bigger problem.
  2. Think of the simplest version of the problem, something you can already solve.
    • This is called the base case.
    • Usually something like solve for 0 or the empty list
  3. Combine them to solve the problem.
(define (find-closest goal numbers)
   (if (= 1 (length numbers))
   (first numbers)
       (if (< (abs (- goal (first numbers)))
                (abs (- goal 
                          (find-closest goal (rest numbers)))))
           (first numbers)
           (find-closest goal (rest numbers))))


Ghost Cat by Clay Yount (CS200 Spring 2002 graduate!), Cavalier Daily, 24 January 2003.


Links
CS 200


CS 200: Computer Science
Department of Computer Science
University of Virginia

cs200-staff@cs.virginia.edu
Using these Materials