|
CS 3343/3341 Analysis of Algorithms Spring 2012 Recitation 4 Binary Search Tree, Etc. Complete Answers |

_ _ _ _
| 0 1 |^n | F(n-1) F(n) |
Need to prove that |_1 1_| = |_F(n) F(n+1)_|, for all n >= 1
Let n = 1
-----------
_ _ _ _
| 0 1 |^1 | 0 1 |
|_1 1_| = |_1 1_|
This is true because:
F(n-1) = F(1-1) = F(0) = 0
F(n) = F(1) = 1
F(n+1) = F(1+1) = F(2) = 1
_ _ _ _
| 0 1 |^k | F(k-1) F(k) |
Now assume that |_1 1_| = |_F(k) F(k+1)_|, for any k >= 1
Now let n = k + 1
To prove:
_ _ _ _
| 0 1 |^(k+1) | F(k) F(k+1) |
|_1 1_| = |_F(k+1) F(k+2)_|
------------------
_ _ _ _ _ _
| 0 1 |^(k+1) | 0 1 |^k| 0 1 |
|_1 1_| = |_1 1_| |_1 1_|
_ _ _ _
| F(k-1) F(k) || 0 1 | (Based on assumption
= |_F(k) F(k+1)_||_1 1_| from above)
_ _
| F(k-1)*0 + F(k)*1 F(k-1)*1 + F(k)*1 | (Multiplying)
= |_F(k)*0 + F(k+1)*1 F(k)*1 + F(k+1)*1_|
_ _
| F(k) F(k-1) + F(k) | (Simplifying)
= |_F(k+1) F(k) + F(k+1)_|
_ _
| F(k) F(k+1) | (Using the definition of Fibonacci Sequence)
= |_F(k+1) F(k+2)_|
We have proved that
o the identity holds for n=1,
o if it holds for an arbitrary k >= 1, then it holds for k + 1
So by induction, we conclude that the Fibonacci matrix identity is true.]
| The Fibonacci Numbers: F0 = 0 F1 = 1 Fn = Fn-1 + Fn-2, n > 1 |
The Leonardo Numbers: A0 = 1 A1 = 1 An = An-1 + An-2 + 1, n > 1 |
| An = 2 * Fn+1 - 1 |
Note: The following kind of proof is NOT what you are to do:
"Based on the variable y, this program will clearly iterate y times. Each time, starting with 0, we keep adding x to a running sum. In the end, we've added in x a total of y times, so x + x + ... + x (y times) is obviously x*y, which is what mult is supposed to do."
// mult: inputs X and Y both > 0
int mult(int X, int Y) {
int x = X, y = Y, p = 0;
while (y > 0) {
p = p + x;
y = y - 1;
}
return p;
} |
|
![]() Click picture or here for full size picture. |