Lecture C13: Recurrence equations
Response to 'Muddiest Part of the Lecture Cards'
(40 respondents)
1)
What does Recurrnece Equations got to do with programming?
and similar questions (6 students)
Recurrence equations provide a means of expressing the cost of an algorithm as a function of the size of
the input. For example, with the Towers of Hanoi problem, moving 4 disks from tower 1 to tower 3 can
be broken down into:
●
Moving 3 disks from tower 1 to tower 2
●
Moving 1 disk from tower 1 to tower 3
●
Moving 3 disks from tower 2 to tower 3.
If the cost of solving n disks is T(n), from the above breakdown, we can express T(n) as:
C when n = 1
T(n)
=
2T(n1) + c when n >
1
This above representation is called a recurrence equation with T(n = 1) being the base case.
2)
What exactly does the cost of a procedure entail? What is the benefit of calculating the efficiency/
cost of a function?
and similar questions (5 students)
The cost of an algorithm can be measured in terms of memory usage, processor usage or a combination
of the two. When you are trying to compare the efficiency of two or more algorithms, you want to be
able to compute the cost of the problem as a function of the size of the problem. The two functions can
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.
 Winter '12
 CharlesColeman
 Remainder, Aeronautics, Astronautics, Greatest common divisor, Euclidean algorithm, recurrence equation, Recurrnece Equations

Click to edit the document details