The Art of Recursion: Problem Set 2
Due Tuesday, 18 September 2012
Strong Induction and Memoization
Consider the following recursive denition of the Fibonacci numbers:
F0 = 0
F1 = 1
Fn = Fn1 + Fn2
when n 2.
1. Implement a recursive function b(n) which tak
The Art of Recursion: Problem Set 10
Due Tuesday, 20 November 2012
Tail recursion
A recursive function is tail recursive if every recursive call is in tail
positionthat is, the result of the recursive call is immediately the
result of the whole function;
The Art of Recursion: Problem Set 9
Due Tuesday, 13 November 2012
Mutual recursion
Mutual recursion refers to a situation where two or more functions are
dened in terms of each other. That is, the functions are not directly
recursive, but (say) f calls g
The Art of Recursion: Problem Set 8
Due Tuesday, 6 November 2012
Termination Analysis
As we have seen, programming systems which allow arbitrary recursion (such as the untyped -calculus, or Haskell) do not make for a
good foundation for mathematics and pr
The Art of Recursion: Problem Set 7
Due Tuesday, 30 October 2012
This problem set will allow you to explore the Haskell programming language, and use it in turn to explore some aspects of recursion.
See http:/www.cis.upenn.edu/~cis194/resources.html for l
The Art of Recursion: Problem Set 6
Due Tuesday, 16 October 2012
Recall our motivation for introducing types to the -calculus: we
want to rule out innitely reducing terms like . The problem with
(and similar sorts of terms) seems to be self-application:
The Art of Recursion: Problem Set 5
Due Tuesday, 9 October 2012
1. Prove: for all n 0,
(1 + 2 + + n)2 = 13 + 23 + + n3 .
2. What is the largest amount of postage that cannot be paid
exactly using any combination of ve-cent and seven-cent
stamps? For examp
The Art of Recursion: Problem Set 4 (ver. 3)
Due Tuesday, 2 October 2012
Recall that terms of the -calculus are dened by the following
algebra:
= cfw_Var, Lam, App
T = cfw_Name, Term
Ty(Var) = Name Term
Ty(Lam) = Name Term Term
Ty(App) = Term Term Term
W
The Art of Recursion: Problem Set 3 (ver. 3)
Due Tuesday, 25 September 2012
1.
1
Prove: for all n 1,
1+
11
1
+ + + 2 < 2.
49
n
Consider the multi-sorted algebra of lists with natural numbers as
data that we saw in class, dened by:
= cfw_Nil, Cons
T = cf
The Art of Recursion: Problem Set 11
Due Tuesday, 27 November 2012
Lazy evaluation
Most programming languages use strict evaluation: when evaluating a
function call, the arguments to the function are completely evaluated
before calling the function. In a