Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Notes  >  Algorithms  >  Previous Year Questions: Recurrence Relation

Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) PDF Download

Q1: Let T(n) be the recurrence relation defined as follows:
T(0) =1
T(1) = 2, and
T(n) = 5T (n - 1) - 6T(n - 2) for n ≥ 2
Which one of the following statements is TRUE?  (2024 SET-2)
(a) T(n) = Θ (2n)
(b) T(n) = Θ (n2n)
(c) T(n) = Θ (3n)
(d) T(n) = Θ (n3n)
Ans: 
(a)
Sol: 

Given
T0 = 1; T1 =2; T= 5Tn-1 - 6Tn-2 for (n  ≥ 2)
Observations
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
A is invertible 2 × 2 matrix. Hence, we can use the power of diagonalization to solve for An−1 neatly.
Diagonalization
∧ =  P-1 AP or A = P∧ P-1  where ∧  is 2 x 2  diagonal matrix and ∧i,i = λi, here λi is eigen value of A. P is 2 x 2 invertible matrix such that P = (e1 e2) where eis eigenvector corresponding to λi. Hence, using diagonalization we can represent any matrix in terms of its eigenvalues and eigenvectors.
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Eigen values of A are Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Final Equation
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Q2: Consider the following recurrence relation:
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Which one of the following options is CORRECT?  (2024 SET-1)
(a) T(n) = Θ(n log log n)
(b) T(n) = Θ(n log n)
(c) T(n) = Θ(n2 log n)
(d) T(n) = Θ(n2 log log n)
Ans: (a)
Sol:
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Option (A) is correct
Clarification over Solution to  Q(K)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Q3: For constants a ≥ 1 and b >1, consider the following recurrence defined on the non-negative integers:
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Which one of the following options is correct about the recurrence T(n)?  (2021 SET-2)
(a) if f(n) is n log2(n), then T(n) is Θ (n log2(n)).

(b)Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
(c)Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
(d)Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Ans: (c)
Sol: Options A and B are definitely wrong, condition on f(n) can’t be independent of a and b in any case, it should take both a and b into account.
Option C is correct. standard case of master theorem, if f(n) is polynomial time smaller thanPrevious Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Then Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)(see case 1 below).
Theorem 4.1 (Master theorem)
Let a ≥ 1 and b > 1 be constants, let f(n) be a function, and let t(n) be defined on the nonnegative integers by the recurrence
T(n) = aT(n/b) + f(n),
where we interpret n/b to mean either [n/b] or [n/b]. Then T(n) has the following asymptotic bounds:
IfPrevious Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) for some constant  ε > 0, Then  Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
IfPrevious Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) Then Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
IfPrevious Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) for some constant  ε > 0, and if af(n/b) ≤ cf(n) for some constant c < 1 and all sufficiently large n,
then T(n) = Θ(f(n)).

Q4: Consider the following recurrence relation.
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) 
Which one of the following options is correct?  (2021 SET-1)
(a) T(n) = Θ(n5/2)

(b) T(n) = Θ(n log n)
(c) T(n) = Θ(n)
(d) T(n) = Θ((log n)5/2)
Ans: (c)
Sol: 
At first, draw two levels of the recursion tree:
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Size of the problem will reduce as we go down a level each time in the tree.
Hence, in this case root will be the dominant part.
Final ans is  T(n) = Θ(n) (order of the root) (you have to ans in less than 30 sec!)
Let Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
When Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) since Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)is a constant.
We can see that the size of problem reduces geometrically, and root is the dominating part.
Note: Apply the following method for divide and conquer recursions because the size of the problem reduces geometrically. Not for subtract and conquer where it might reduce arithmetically!
And to apply this idea, all the conditions of Master theorem must be satisfied.
Everything given below is not required for GATE, it's just to explain the idea.
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
T(1) = c
(Assume all conditions of the Master theorem to be true here, b > 1).Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Let height of this tree be h,
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
No. of leaves Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Here’s the relation with master theorem:
Case 1 (root is dominant): Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
This case of Master theorem says T(n) = Θ (nk), which is nothing but the order of root.
(We are kind a deriving cases of the master theorem using intuition)
Case 2 (root is equal to all levels): Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
According to the Master theorem, T(n) = Θ(nk log(n)).
All the levels are equally dominant, hence final result will be the sum of all levels.
That is, size of a particular level × the height  ⇒ nk x logb(n), Hence T(n) =  Θ (nlogb(n)).
Case 3 (leaf level is dominant):  
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) 
As the leaves’ levels are dominant, Ans will be in the order of the leaf’s level = Order of no of leaves in the tree (because base condition will be a constant)
Hence Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Q5: The master theorem  (2020)
(a) assumes the subproblems are unequal sizes
(b) can be used if the subproblems are of equal size
(c) cannot be used for divide and conquer algorithms
(d) cannot be used for asymptotic complexity analysis
Ans:
(b)
Sol: 
It divides the subproblem into each of size n/b.

Q6: For parameters a and b, both of which are ω(1),T(n) = T(n1/a)+1, and T(b) = 1. Then T(n) is   (2020)
(a) Θ(loga logb n)
(b) Θ(logab n)
(c) Θ(logb logn)
(d) Θ(log2 log2 n)
Ans: 
(a)
Sol:

Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Now, Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
After k iterations, Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
When Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
[∵ a&b are ω(1), so a&b are some function of n and not constant. So a&b can’t be replaced with 2]
So, option D is rejected.
Now, Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
So, the correct answer is A.

Q7: The running time of an algorithm is given by:
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Then what should be the relation between T(1), T(2), T(3), so that the order of the algorithm is constant?  (2018)
(a) T(1) = T(2) = T(3)
(b) T(1) + T(3) = 2T(2)
(c) T(1) - T(3) = T(2)
(d) T(1) + T(2) = T(3)
Ans: 
(a)
Sol: 
For sufficiently large n,
T(n) = Tn - 1) + T(n - 2) - T(n - 3)
If the order of the algorithm for which above recurrence is applicable for the time complexity, is a constant,
T(n) =T(n-1).
⇒ T(n) = T(n) + T(n - 2) - T(n - 3)
⇒ T(n - 2 = T(n - 3)
Going like this, we must have T(1) = (T(2) = T(3).

Q8: The recurrence relation that arises in relation with the complexity of binary search is:  (2017)
(a) T(n) = 2T (n/2) + k, k is a constant
(b) T(n) = T (n/2) + k, k is a constant
(c) T(n) = T (n/2) + log n
(d) T(n) = T (n/2) + n
Ans: 
(b)
Sol: 
Searching for only one half of the list. leading to T(n/2) + constant time in comparing and finding mid element.

Q9: Consider the recurrence function
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Then T(n) in terms of θ notation is  (2017 SET-2)
(a) θ(loglogn)
(b) θ(logn)
(c) θ(√n)
(d) θ(n)
Ans:
(b)
Sol: 
T(n) = 2T(√n) + 1
Put, n =2m which implies √n = n1/2 = 2m/2
⇒ T(2m) = 2T(2m/2) + 1
Put, T(2m) = S(m) which implies T(2m/2) = S(m/2)
⇒ S(m) = 2S(m/2) + 1
Using case 1 of master method ,
= Θ(m) = Θ (log n)

Q10: Consider the following recurrence:
T(n) = 2T(√n) + 1, T(1) = 1
Which one of the following is true?  (2016)
(a) T(n) = Θ(log log n)
(b) T(n) = Θ(log n)
(c) T(n) = Θ(√n)
(d) T(n) = Θ(n)
Ans: 
(b)
Sol: Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Q11: 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 i<j. 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_______.  (2014 SET-3)
(a) 100
(b) 150
(c) 50
(d) 200
Ans: 
(b)
Sol: 
T(k) is the smallest number of steps needed to move from k to 100.
Now, it is given that y and z are two numbers such that,
T(9) = 1 + min(T(y), T(z)), i.e.,
T(9) = 1 + min (Steps from y to 100 , Steps from z to 100), where y and z  are two possible values that can be reached from 9.
One number that can be reached from 9 is 10, which is the number obtained if we simply move one position right on the number line. Another number is 15, the shortcut path from 9, as given in the question. So, we have two paths from 9, one is 10 and the other is 15.
Therefore, the value of y and z is 10 and 15 (either variable may take either of the values).
Thus, yz = 150.

Q12: Which one of the following correctly determines the solution of the recurrence relation with T(1) = 1?  (2014 SET-2)
T(n) = 2T(n/2) + logn
(a) θ(n)
(b) θ(nlogn)
(c) θ(n2)
(d) θ(logn)
Ans:
(a)
Sol: 
f(n) = log n
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
So, f(n) = log n = O (n1- ϵ) we can take any ϵ from 0-1 for example 0.5 which gives log n = O(√(n)),
So, Master theorem Case 1, and answer will be Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Alternate way:
T(1) = 1T(2) = 2T(1) + log2 = 3 = 3n - 2T(4)
= 2T(2) + log 4 = 8= 3n - 4T(8)
= 2T(4) + log 8 = 19 = 3n - 5T(16
= 2T(8) + log 16 = 42 = 3n - 6
The second term being subtracted is growing at a lower rate than the first term. So, we can say T(n) = O(n).

Q13: The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with n discs is  (2012)
(a) T(n) = 2T(n - 2) + 2
(b) T(n) = 2T(n - 1) + n
(c) T(n) = 2T(n/2) + 1
(d) T(n) = 2T(n - 1) + 1
Ans:
(d)
Sol: 
Recurrence relation for Towers of Hanoi is
T(1) = 1
T(n) = 2T(n - 1) + 1
So Answer should be (D)

Q14: Let T(n) be defined by T(1) = 10 and T(n + 1) = 2n + T(n)  for all integers n ≥ 1.
Which of the following represents the order of growth of T(n) as a function of n?  (2011)
(a) O(n)
(b) O(n log n)
(c) O(n2)
(d) O(n3)
Ans: 
(c)
Sol: 
T(n + 1) = 2n + T(n)
= 2n + 2(n - 1) + T(n - 1)
= 2n + 2(n - 1) + 2(n - 2) + T(n - 2).....
= 2n + 2(n - 1) + 2(n - 2)... 2(1) + T(1)
= 2(n + n - 1 + n - 2.....1) + T(1)
= Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
= O(n2)

Q15: The running time of an algorithm is represented by the following recurrence relation:
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Which one of the following represents the time complexity of the algorithm?  (2009)
(a) θ(n)
(b) θ(n log n)

(c) θ(n2)
(d) θ(n2logn)
Ans: 
(a)
Sol: 
Comparing with the recurrence form of Master Theorem
T(n) = aT(n/b) + f(n)
a = 1, b = 3, logb a = 0
SoPrevious Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
f(n) = cn
So, Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) holds for any ϵ < 1 and this is the third case of Master theorem. But Master theorem also requires (only case 3) that regularity condition be satisfied (this ensures that f(n) is still dominant when the recurrence go deeper) which is af(n/b) ≤ df(n) for some d < 1 and all sufficiently large n.(Using d here as c is already used in f(n))
Here we get, f(n/3) ≤ df(n)
⇒ cn/3 ≤ dcn ⇒ 1/3 ≤ d
Thus we can use any 1/3  ≤ d < 1 to satisfy the regularity condition and Master theorem case 3 is satisfied. Now, applying case 3 we get
T(n) = Θ(f(n)) = Θ(n)

Q16: When n =2k  for some k ≥ 0, the recurrence relation T(n) = √(2)T(n/2) + √n, T(1) = 1 evaluates to :  (2008)
(a) √(n) (log n+1)

(b) √(n) log n
(c) √(n) log √(n)
(d) n log √n
Ans:
(a)
Sol: 
T(n) = √(2) T (n/2) + √n
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
If we use Master theorem we get option B. But one must know that Master theorem is used to find the asymptotic bound and not an EXACT value. And in the question here it explicitly says "evaluates to".

Q17: Let xdenote the number of binary strings of length n that contain no consecutive 0s.  (2008)
The value of x5 is                            
(a) 5
(b) 7
(c) 8
(d) 16
Ans: 
(c)    
Sol: 
We can write the recurrence for the number of binary strings of length n without consecutive 0s as

  • T(n) = T(n - 1) + T(n - 2);    n> 2
  • T(1) = 2; T(2) = 3

The reason for this recurrence can be seen as follows:

  • A string of length n without 00 can be formed by adding
    • a 1 to any string without 00 of length n - 1 →T(n - 1)
    •  a 0 to any string ending in and without 00 of length n - 1 →T(n-2)
    • These two cases are mutually exclusive (no common strings) and exhaustive (no strings outside

      these two cases). So, we can just add the two cases to get T(n)

T(1) = 2 - {0,1}
T(2) = 3 - {01, 10, 11}
T(3) = T(1) + T(2) = 2 + 3 = 5
T(4) = T(3) + T(2) = 5 + 3 = 8
T(5) = T(4) + T(3) = 8 + 5 = 13
Hence, the answer is 13.

Q18: Let xn denote the number of binary strings of length n that contain no consecutive 0s.
Which of the following recurrences does xsatisfy?  (2008)
(a) x= 2xn-1
(b) xn = x[n/2] + 1
(c) xn = x[n/2] + n
(d) xn = Xn-1 + xn-2
Ans:
 (d) 
Sol: 
01 - 2
01 10 11 - 3
010 011 101 110 111 - 5
0101 0110 0111 1010 1011 1101 1110 1111- 8
SO, xn = xn-1 + xn-2 (For all the strings ending in 1, we get two new strings ending in either 0 or 1 and for all strings ending in 0, we get a new string ending in 1. So, the new set of strings for xn, will have exactly xn-1 strings ending in 1 and xn-2 strings ending in 0)
x5 = 8 + 5 =13.

Q19: Consider the following recurrence:
T(n)=2T([√n]) + 1, T(1) = 1
Which one of the following is true?  (2006)
(a) T(n)=Θ(loglogn)
(b) T(n)=Θ(logn)
(c) T(n)=Θ(√n)
(d) T(n)=Θ(n)
Ans: 
(b)
Sol:

 Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Q20: Let T(n) be a function defined by the recurrence
T(n) = 2T(n/2) + √n for n ≥ 2 and
T(1) = 1

Which of the following statements is TRUE?  (2005)
(a) T(n) = Θ(log n)
(b) T(n) = Θ(√n)
(c) T(n) = Θ(n)
(d) T(n) = Θ(n log n)
Ans: 
(c)
Sol:  
Option C is the answer. It can be done by Master's theorem.
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
So, Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) is true for any real ϵ, 0 < ϵ < 1/2.
Hence Master theorem Case 1 satisfied,
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Q21: Suppose T(n) = 2T(n/2) + n, T(0) = T(1) = 1
Which one of the following is FALSE?  (2005)

(a) T(n) = O(n2)
(b) T(n) = Θ(n log n)
(c) T(n) = Ω(π2)
(d) T(n) = O(n log n)
Ans: 
(c)
Sol:  
Applying Masters theorem,
T(n) =  Θ(n log n)
So, it cannot be Ω(n2).
Hence, answer is (C).

Q22: Consider a list of recursive algorithms and a list of recurrence relations as shown below. Each recurrence relation corresponds to exactly one algorithm and is used to derive the time complexity of the algorithm.
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Which of the following is the correct match between the algorithms and their recurrence relations?  (2004)
(a) P-II, Q-III, R-IV, S-I
(b) P-IV, Q-III, R-I, S-II
(c) P-III, Q-II, R-IV, S-I
(d) P-IV, Q-II, R-I, S-III

Ans: (b)
Sol: For binary search on n elements we pick a path of n/2 elements after doing a single comparison (0(1)) and discard the remaining n/2 elements So, T(n) = T(n/2) + 1.
For merge sort on n elements we divide the array into two equal parts containing n/2 elements, recursively merge sort them and finally merges the 2 arrays in O(n) time. So,
T(n) = 2T(n/2) + сn.
For quick sort on n elements we split the array based on the position of the pivot. If pivot happens to be the k + 1th element in the sorted array, we do a recursive call using k elements and n - k - 1 elements and we need O(n) time to decide the position of the pivot.
So, T(n) = T(n - k - 1) + T(k) + cn. (A -1 is missing in the question option).
For Tower of Hanoi using n disks, to position the first disk we have to replace n 1 disks two times. To place the remaining disks we have to recursively solve the problem thus giving T(n) = 2T(n - 1) + 1.

Q23: The recurrence equation  (2004)
T(1) = 1
T(n) = 2T(n - 1) + n, n ≥ 2
evaluates to
(a) 2n+1 - n - 2
(b) 2n- n
(c) 2n+1 - 2n - 2
(d) 2+ n
Ans:
(a)
Sol: 

Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Q24: Consider the following recurrence relation  (2003)
T(1)=1
T(n+1)=T(n)+ [√n + 1] for all n ≥ 1
The value of T(m2) for m ≥ 1 is
(a) (m/6) (21m - 39) + 4
(b) (m/6) (4m2 - 3m + 5)
(c) (m/2) (m2.5 - 11m + 20) - 5
(d) (m/6) (5m3- 34m+ 137m - 104) + (5/6)
Ans: 
(b)
Sol:

 Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
(We are taking floor of square root of numbers, and between successive square roots number of numbers are in the series 3, 5, 7... like 3 numbers from 1..4, 5 numbers from 5 - 9 and so on).
We can try out options here or solve as shown at end:
Put m = 5, T(25) = 3 x 1 + 5 × 2 + 7 × 3 + 9 × 4 + 5 = 75
A. 59
B. 75
C. non-integer
D. 297.5
So, answer must be B.

Q25: The running time of the following algorithm
Procedure A(n)
If n ≤ 2 return (1) else return (A(√n));  (2002)
is best discribed by
(a) O(n)
(b) O(log n)
(c) O(loglogn)
(d) 0(1)
Ans: 
(c)
Sol: 
The complexity will be the number of times the recursion happens which is equal to the number of times we can take square root of n recursively, till n becomes 2.
T(n) = T([√n]) + 1
T(2) = 1
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
So, T(n) = lg lg n + 1 = O(log log n)

Q26: The solution to the recurrence equation T(2k) =  3T (2k-1) + 1, T(1) = 1 is  (2002)
(a) 2k
(b)Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

(c)Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) 
(d)Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Ans: (b)
Sol: 
Let x = 2
T(x) = 3T(x/2) + 1
We can apply Master's theorem case 1 with a = 3 and b = 2 asPrevious Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
So,Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
So, only option possible is B.
We can also directly solve as follows:
T(x) = 3T(x/2)+1
= 9T (x/4) + 1 + 3
:
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
(recursion depth is log2 x and x = 2k)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
(Sum to n terms of GP with a = 1 and r = 3)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
OR
T (2k) = 3T (2k-1) +1
= 32T (2k-2) + 1 + 3
:
= 3kT (2k-k) + (1 + 3 + 9 + ... + 3 - 1)
(recursion depth is k)
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Q27: The recurrence relation  (1996)                               
T(1) = 2
T(n) = 3T(n/4) + n
has the solution T(n) equal to
(a) O(n)

(b) O(log n)
(c) O(n3/4)
(d) None of the above
Ans: 
(a)
Sol: 
According to Master theorem,
T(n) = aT(n/b) + f(n) can be expressed as:
Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)
Where u(n) = Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) 
where r = 0.
So, Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

Q28: The recurrence relation that arises in relation with the complexity of binary search is:  (1994)
(a) T(n) = 2T (n/2) + k, k is a constant
(b) T(n) = T (n/2) + k, k is a constant
(c) T(n) = T (n/2) + log n
(d) T(n) = T (n/2) + n
Ans: 
(b)
Sol: 
Searching for only one half of the list. leading to T(n/2) +  constant time in comparing and finding mid element.

The document Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Algorithms.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
81 videos|80 docs|33 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Previous Year Questions: Recurrence Relation - Algorithms - Computer Science Engineering (CSE)

1. What is a recurrence relation?
Ans. A recurrence relation is an equation that recursively defines a sequence based on a given formula relating terms of the sequence.
2. How do you solve a recurrence relation?
Ans. Recurrence relations can be solved using various methods such as substitution, iteration, generating functions, or the master theorem, depending on the complexity of the relation.
3. What is the difference between a linear and a non-linear recurrence relation?
Ans. A linear recurrence relation has terms that are linear combinations of previous terms, while a non-linear recurrence relation involves non-linear combinations of terms.
4. How can recurrence relations be used in computer science and mathematics?
Ans. Recurrence relations are commonly used in algorithm analysis, complexity theory, combinatorics, and discrete mathematics to model and solve various problems efficiently.
5. Can recurrence relations be applied in real-world scenarios outside of mathematics?
Ans. Yes, recurrence relations can be used to model and analyze various real-world phenomena such as population growth, economic trends, and the spread of diseases.
81 videos|80 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Free

,

Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

,

Sample Paper

,

study material

,

video lectures

,

Objective type Questions

,

Previous Year Questions with Solutions

,

Important questions

,

Exam

,

practice quizzes

,

shortcuts and tricks

,

pdf

,

Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

,

Summary

,

Semester Notes

,

MCQs

,

ppt

,

past year papers

,

Extra Questions

,

Previous Year Questions: Recurrence Relation | Algorithms - Computer Science Engineering (CSE)

,

mock tests for examination

,

Viva Questions

;