Q1: The Lucas sequence Ln is defined by the recurrence relation:
Ln = Ln−1 + Ln−2, for n ≥ 3,
with L1 = 1 and L2 = 3
Which one of the options given is TRUE? (2023)
(a)
(b)
(c)
(d)
Ans: (a)
Sol: By using n = 1, options can be eliminated easily and there are methods like solving linear homogeneous recurrenceby making characteristic equation, generating function etc.
As answer is added here by converting Ln − Ln−1 − Ln−2 = 0 to characteristic equation r2 − r − 1 = 0 by assuming solution Ln = crn; c > 0
But the question is “why” we assume so ?
So, we can use an approach of Linear Algebra and prove that our assumption is correct because it is difficult to assumesomething while solving this question first time because we might find difficulty to assume it without having any reason.
So,this method is long but answer your question of "Why ?"
Here, we have given a difference equation of order two as Ln = Ln−1 + Ln−2 ;n ≥ 3
The idea is, we will make the system of two simultaneous difference equations of order one from this linear difference equationof order 2 and then write it in the matrix form and solve this system.
Assume, Ln−2 = Mn−1 or Mn = Ln−1
And this way, we have a system of two difference equations of order one as :
Ln = Ln−1+Mn−1 (1)
Mn = Ln−1+0Mn−1 (2)
Now, if we write this system in the matrix form as:
Now, we replace
So,
In this way, we get,
Hence,
Now, say,
Now, to find An−2, we need to find An and for that we can use the idea of Cayley-Hamilton theorem.
(An can be computed with the use of Diagonalization concept by finding eigenvalues and eigenvectors for the matrix A.)
Suppose, λ is an eigenvalue for the matrix A. So characteristic equation will be:
det(A - λI) = 0
So, characteristic equation will be:
λ2 - λ - 1 = 0
This is the same characteristic equation which we got while solving linear homogeneous recurrence and so, you can say, this is a proof for making that characteristic equation for linear homogeneous recurrence withconstant coefficient without assuming solution of the recurrencein the form of cλn or λn.
Now, According to the Cayley-Hamilton theorem, every square matrix A satisfies its characteristic equation and so,
A2 - A - I = 0
A2 = A + I
A3 = A2 + A = 2A + I
A4 = 2A2 + A = 3A + 2I
Hence, you can write An = aA + bI for some arbitrary constant a and b.
Hence,
So, and
Since, λ2 −λ − 1 = 0 gives
So, we get,
Now, put a and b in An = aA + bI, we get:
And so,
Now, finally, by (3), we get:
After solving it, we get,
Q2: Consider the following recurrence:
f(1) = 1;
f(2n) = 2f(n) − 1, for n ≥ 1;
f(2n + 1) = 2f(n) + 1, for n ≥ 1.
Then, which of the following statements is/are TRUE?
MSQ (2022)
(a) f(2n−1) = 2n−1
(b) f(2n) = 1
(c) = 2n+1+1
(d) f(2n + 1) = 2n + 1
Ans: (a, b, c)
Sol: Edit: To do this question quickly in exam, you can do something like informal induction:
A) Let, f(2n−1) = 2n−1 is true for all natural n≥1, it means f(2n−1−1) = 2n−1−1 is also true for n ≥ 2.
Now,
f(2n − 1) = f((2n − 1 − 1) + 1) = f(2n − 2 + 1) = f(2(2n−1−1) + 1)
= 2f(2n−1−1) + 1 = 2(2n−1−1) + 1 = 2n−1
Similarly,
B) f(2n) = f(2 × 2n−1) = 2f(2n−1) − 1 = 2 × 1 − 1 = 1
C) f(5.2n) = f(2(5 × 2n−1)) = 2f(5 × 2n−1) − 1
= 2 × (2n + 1) − 1 =2n+1 + 1
D) f(2n+1) = f(2 × 2n−1 + 1) = 2f(2n−1) + 1 = 2 × 1 + 1 = 3
Hence, A, B and C are correct options
00 01 10 −3 (append both 0 and 1 to any string ending in 0, and append 0 to any string ending in 1)
000 001 010 100 101 − 5 (all strings ending in 0 give two strings and those ending in 1 give 1 string)
0000 0001 0010 0100 0101 1000 1001 1010 − 8
⋮
(where an denote the number of bit strings of length n containing two consecutive 1s)
2n − an = (2n−1 − an−1) + (2n−2 − an−2)
an = 2n−2(4 − 2 − 1) + an−1 + an−2
an = an−1 + an−2 + 2n−2
Correct Option: A
34 videos|115 docs|72 tests
|
1. What is a recurrence relation in computer science? |
2. How are recurrence relations used in algorithms and data structures? |
3. Can you give an example of a recurrence relation used in computer science? |
4. How can we solve recurrence relations in computer science? |
5. Why is understanding recurrence relations important for computer scientists and programmers? |
34 videos|115 docs|72 tests
|
|
Explore Courses for Computer Science Engineering (CSE) exam
|