Recurrence Relation · Algorithms
24 questions · asked in 15 of 27 years (2000–2026)
MCQ 22 · MSQ 1 · NAT 11-mark 15 · 2-mark 9
2000Questions per year2026
Questions 11–15 of 24
Suppose you want to move from 0 to 100 on the number line. In each step, you either move right by a unit distance or you take a shortcut. A shortcut is simply a pre-specified pair of integers i,j with . Given a shortcut i, j if you are at position i on the number line, you may directly move to j. Suppose T(k) denotes the smallest number of steps needed to move from k to 100. suppose further that there is at most 1 shortcut involving any number, and in particular from 9 there is a shortcut to 15. Let y and z be such that T(9) = 1 + min(T(y), T(z)). Then the value of the product yz is_______.
Answer: 150
At 9, there are two choices: move one step right to 10, or use the shortcut to 15.
Recurrence: so y = 10 and z = 15
The product is yz = 150
Answer: 150
Recurrence: so y = 10 and z = 15
The product is yz = 150
Answer: 150
The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with n discs is
Answer: (D)
First, shift the top n 1 discs to the spare peg. Next, make 1 move for the largest disc. Last, place the n 1 discs back on top of it.
This gives the recurrence:
T(n) = 2T(n 1) + 1
Answer: T(n) = 2T(n 1) + 1
This gives the recurrence:
T(n) = 2T(n 1) + 1
Answer: T(n) = 2T(n 1) + 1
The running time of an algorithm is represented by the following recurrence relation:
Which one of the following represents the time complexity of the algorithm?
Which one of the following represents the time complexity of the algorithm?
Answer: (A)
Compare the given recurrence with the Master Theorem form
This gives
So is true for any . This is the third case of the Master theorem. The Master theorem also needs one more check in case 3, the regularity condition. This check makes sure still dominates as the recurrence goes deeper. The condition is for some and all large enough (we write here because is already used in
Here we have
So any satisfies the regularity condition, and case 3 of the Master theorem holds. Now we apply case and get
The answer is A.
When for some , the recurrence relation
evaluates to :
evaluates to :
Answer: (A)
Expand the recurrence step by step:
Each added term is the same: , and in general . The recursion reaches after levels (with ), so there are such terms.
The last term is .
The Master theorem would give only , which is option (B). But it gives only an asymptotic bound, not the exact value, and the question asks what the recurrence evaluates to. Check: gives and , and . Option (B) would give 4.
Answer: (A)
Each added term is the same: , and in general . The recursion reaches after levels (with ), so there are such terms.
The last term is .
The Master theorem would give only , which is option (B). But it gives only an asymptotic bound, not the exact value, and the question asks what the recurrence evaluates to. Check: gives and , and . Option (B) would give 4.
Answer: (A)
Let denote the number of binary strings of length n that contain no consecutive 0s.
The value of is
The value of is
Answer: (C)
Let be the number of binary strings of length with no two consecutive 0s. Split by the last bit.
- Ends in 1: the first bits can be any valid string, giving strings.
- Ends in 0: the bit before it must be 1, so the string is a valid string of length followed by 10, giving strings.
The two cases share no string and cover all, so .
Start: (0, 1) and (01, 10, 11).
, , .
Answer: (C)
- Ends in 1: the first bits can be any valid string, giving strings.
- Ends in 0: the bit before it must be 1, so the string is a valid string of length followed by 10, giving strings.
The two cases share no string and cover all, so .
Start: (0, 1) and (01, 10, 11).
, , .
Answer: (C)
Keep practising