notes17 - When a process has this structure Scheme does not...

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: When a process has this structure, Scheme does not need extra memory to remember all the unfinished tasks during the computation. This is really not a big deal. For the purposes of this course, you should generally use the simpler linear- recursive structure and not try for the more complicated iterative structure; the efficiency saving is not worth the increased complexity. The reason Abelson and Sussman make a fuss about it is that in other programming languages any program that is recursive in form (i.e., in which a function invokes itself) will take (at least) linear space even if it could theoretically be done iteratively. These other languages have special iterative syntax ( for , while , and so on) to avoid recursion. In Scheme you can use the function-calling mechanism and still achieve an iterative process. • More is less: non-obvious efficiency improvements. The n th row of Pascal’s triangle contains the constant coefficients of the terms of ( a + b ) n . Each number in Pascal’s triangle is the sum of the two numbers above it. So we can write a function to compute thesein Pascal’s triangle is the sum of the two numbers above it....
View Full Document

This note was uploaded on 02/17/2010 for the course COMPUTER S 26275 taught by Professor Harvey,b during the Spring '10 term at Berkeley.

Ask a homework question - tutors are online