The exam covers Modules 1—4 of the course, corresponding to
Chapters 1—4 of the text.
The exam has 50 points, with about half multiple-choice.
See the menu for examples of the types of problems you may see on the exam.
Classify the following as to whether it exhibits linear
recursion, linear iteration, logarithmic recursion, logarithmic iteration, or
tree recursion.
(define c-curve
(lambda (x0 y0 x1 y1 level)
(if (= level 0)
(line x0 y0 x1 y1)
(let ((xmid (/ (+ x0 x1) 2))
(ymid (/ (+ y0 y1) 2))
(dx (- x1 x0))
(dy (- y1 y0)))
(let ((xa (- xmid (/ dy 2)))
(ya (+ ymid (/ dx 2))))
(overlay (c-curve x0 y0 xa ya (- level 1))
(c-curve xa ya x1 y1 (- level 1))))))))
Write a procedure to produce a quilting basic block, for
example test-bb.
The procedure below generates a recursive process for computing the sum of the
first
n positive integers. Rewrite it so that it uses
iteration.
(define sum-of-first
(lambda (n)
(if (= n 0)
0
(+ n (sum-of-first (- n 1))))))
Prove by mathematical induction that the
sum-of-first procedure
below works as advertised.
(define sum-of-first
(lambda (n)
(if (= n 0)
0
(+ n (sum-of-first (- n 1))))))
A parenthesized list of expressions the first of whose values is a
Racket procedure is called
- a lambda expression
- an application
- a predicate
- a conditional
Write a Racket procedure called
root that computes the
formula:
Here is an example of its use:
> (let ((a 1)
(b 5)
(c 4))
(root a b c))
3
>
See the menu for the most important concepts by chapter.
- Computational processes
- Scheme expressions and values
- Substitution model of evaluation
- Scheme procedures and predicates
- Scheme arguments and parameters
- Graphics procedures
- Recursion and one-layer thinking
- Procedure verification and mathematical induction
- Base case, induction hypothesis, and inductive step
- Iteration vs. recursion
- Recursive procedure vs. recursive process
- Invariants
- Prime, perfect, and Fermat numbers
- Algorithms
- Selection sort vs. Merge sort
- Order of growth functions using Θ (big theta)
- Digital signatures and modulus arithmetic
- Linear, tree, and logarithmic recursion
- Linear and logarithmic iteration
- Fractal curves