Fibonacci numbers with f. = 1, f. = 1,fibonacci recurrence relation
fr = fn-1 + fn-2 is linear of
options
a) Degree one and homogenous
b) Degree two and homogenous
c) Degree two and non-homogenous
d) None of these
Answers
Answer:
Recurrences
A recurrence describes a sequence of numbers. Early terms are specified explic-
itly and later terms are expressed as a function of their predecessors. As a trivial
example, this recurrence describes the sequence 1, 2, 3, etc.:
T1 D 1
Tn D Tn
The Towers of Hanoi
According to legend, there is a temple in Hanoi with three posts and 64 gold disks
of different sizes. Each disk has a hole through the center so that it fits on a post.
In the misty past, all the disks were on the first post, with the largest on the bottom
and the smallest on top, as shown in Figure 10.1.
Monks in the temple have labored through the years since to move all the disks
to one of the other two posts according to the following rules:
The only permitted action is removing the top disk from one post and drop-
ping it onto another post.
A larger disk can never lie above a smaller disk on any post.
So, for example, picking up the whole stack of disks at once and dropping them on
another post is illegal. That’s good, because the legend says that when the monks
complete the puzzle, the world will end!
To clarify the problem, suppose there were only 3 gold disks instead of 64. Then
the puzzle could be solved in 7 steps as shown in Figure 10.2.
The questions we must answer are, “Given sufficient time, can the monks suc-
ceed?” If so, “How long until the world ends?” And, most importantly, “Will this
happen before the final exam?”
10.1.1 A Recursive Solution
The Towers of Hanoi problem can be solved recursively. As we describe the pro-
cedure, we’ll also analyze the running time. To that end, let Tn be the minimum
number of steps required to solve the n-disk problem. For example, some experi-
mentation shows that T1 D 1 and T2 = 3. The procedure illustrated above shows
that T3 is at most 7, though there might be a solution with fewer steps.
The recursive solution has three stages, which are described below and illustrated
in Figure 10.3. For clarity, the largest disk is shaded in the figures.
Stage 1. Move the top n