# lab4 - <- fib returns 0 ........ <- fib returns 1...

This preview shows pages 1–2. Sign up to view the full content.

Sheet1 Page 1 CS 61AWeek 4 solutions LAB EXERCISES: 1. Error message hunt +: not a number: foo unbound variable: zot eval: bad function in : (3) too many arguments to: (bf 3 5) random: bad number: -7 sqrt: number is negative: -6 Invalid argument to FIRST: () Argument to SENTENCE not a word or sentence:#f define: bad variable name: 5 2. Tracing In a base-case call, the return value comes right after the call: STk> (fib 5) .. -> fib with n = 5 .... -> fib with n = 4 ...... -> fib with n = 3 ........ -> fib with n = 2 .......... -> fib with n = 1<=== Here's a base case .......... <- fib returns 1<=== with its return value .......... -> fib with n = 0 ..........

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: <- fib returns 0 ........ <- fib returns 1 ........-> fib with n = 1 ........ <- fib returns 1 ...... <- fib returns 2 ......-> fib with n = 2 ........-> fib with n = 1 ........ <- fib returns 1 ........-> fib with n = 0 ........ <- fib returns 0 ...... <- fib returns 1 .... <- fib returns 3 .... -> fib with n = 3 ......-> fib with n = 2 ........-> fib with n = 1 ........ <- fib returns 1 ........-> fib with n = 0 ........ <- fib returns 0 ...... <- fib returns 1 ......-> fib with n = 1 ...... <- fib returns 1 .... <- fib returns 2 .. <- fib returns 5 5 Sheet1 Page 2 I count eight base-case calls....
View Full Document

## This note was uploaded on 09/14/2009 for the course PEIS 100 taught by Professor Mckenzie during the Spring '08 term at Berkeley.

### Page1 / 2

lab4 - <- fib returns 0 ........ <- fib returns 1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online