In: Computer Science
Define the following function f(n) =
5(2^n)-(2^(n-1)), n ≥
1. Write a recursive definition for the function f(n)?
Consider the following recurrence: an= 2an-1
+ 3 (where a1 = 1). Compute the values of an
for n ≤ 5. Find a solution for the recurrence definition and
validate its correctness.
Consider the following recurrence: an=2an-1
+an-1an-2 (where a1 = 1). Compute the values
of an for n ≤ 5.
Solution 1
Note that 2n = 2n-1 + 2n-1
f(n) = 5(2^n)-(2^(n-1))
= 5(2^(n-1))
f(n) = 5(2^(n-1))
f(n-1) = 5(2^(n-2))
f(n) = 5(2^(n-1)) = 5(2^(n-2)) * 5(2^(n-2)) =f(n-1) * f(n-1)
Result:
f(n) = f(n-1) * f(n-1)
To verify our result note that:
f(1) = 52 - 1 = 51
f(2) = 54 - 2 = 52 = f(1) * f(1)
f(3) = 58 - 4 = 54 = f(2) * f(2)
f(4) = 516 - 8 = 58 = f(3) * f(3)
f(5) = 532 - 16 = 516 = f(4) * f(4)
Solution 2
an= 2an-1 + 3 (where a1 = 1)
a2= 2a1 + 3 = 2 * 1 + 3 = 5
a3= 2a2 + 3 = 2 * 5 + 3 = 13
a4= 2a3 + 3 = 2 * 13 + 3 = 29
a5= 2a4 + 3 = 2 * 29 + 3 = 61
Note that an= 2n+1 - 3
So a1 = 22 - 3 = 4 -3 = 1
a2 = 23 - 3 = 8 -3 = 5
a3= 24 - 3 = 16 -3 = 13
a4 = 25 - 3 = 32 -3 = 29
a5 = 26 - 3 = 64 -3 = 61
Result
an= 2n+1 - 3
Solution 3
an=2an-1 +an-1an-2 (where a1 = 1)
a2 = 2a1 +a1a0 = 2*1 + 1*0 = 2
a3=2a2 +a2a1 = 2*2 + 2*1 = 4+2 = 6
a4=2a3 +a3a2 = 2*6 + 6*2 = 12+12 = 24
a5=2a4 +a4a3 = 2*24 + 24*6 = 48+144 = 192