Description

This mock test of Test: Recurrence Relations for Computer Science Engineering (CSE) helps you for every Computer Science Engineering (CSE) entrance exam.
This contains 15 Multiple Choice Questions for Computer Science Engineering (CSE) Test: Recurrence Relations (mcq) to study with solutions a complete question bank.
The solved questions answers in this Test: Recurrence Relations quiz give you a good mix of easy questions and tough questions. Computer Science Engineering (CSE)
students definitely take this Test: Recurrence Relations exercise for a better result in the exam. You can find other Test: Recurrence Relations extra questions,
long questions & short questions for Computer Science Engineering (CSE) on EduRev as well by searching above.

QUESTION: 1

Consider the following recurrence relation

The value of T(m2) for m ≥ 1 is

Solution:

One easy way to solve this is to try putting different

values of m.

For example, we know T(1) = 1. If we put m = 1, only A

and B satisfy the result.

m = 2

T(2) = T(1) + 1 = 2

T(3) = T(2) + 1 = 3

T(4) = T(3) + 2 = 5

Both A & B produce 5

m = 3

T(9) = T(4) + 2*5 + 1 = 5 + 10 + 1 = 16

Both A & B produce 16

m = 4

T(16) = T(9) + 3*7 + 1 = 16 + 21 + 1 = 38

Only B produces 38, A produces 34 which doesn't match

QUESTION: 2

The solution to the recurrence equation T(2^{k}) = 3 T(2^{k-1}) + 1, T (1) = 1, is:

Solution:

We have T (2^{k}) = 3 T (2^{k-1}) + 1 = 3^{2} T (2^{k-2}) + 1 + 3 = 3^{3} T (2^{k-3}) + 1 + 3 + 9 . . . (k steps of recursion (recursion depth)) = 3^{k} T (2^{k-k}) + (1 + 3 + 9 + 27 + ... + 3^{k-1}) = 3^{k} + ( ( 3^{k} - 1 ) / 2 ) = ( (2 * 3^{k}) + 3^{k} - 1 )/2 = ( (3 * 3^{k}) - 1 ) / 2 = (3^{k+1} - 1) / 2 Hence, B is the correct choice. Please comment below if you find anything wrong in the above post.

QUESTION: 3

Select the correct asymptotic complexity of an algorithm with runtime T(n, n) where

T(x, c) = Θ(x) for c <= 2,

T(c, y) = Θ(y) for c <= 2, and

T(x, y) = Θ(x+y) + T(x/2, y/2)

Solution:

The recurrence is

T(x, y) = Θ(x+y) + T(x/2, y/2)

It can be written as below.

T(x, y) = Θ(x+y) + Θ((x+y)/2) + Θ((x+y)/4) + Θ((x+y)/8) .....

T(x, y) = Θ((x+y) + (x+y)/2 + (x+y)/4 + (x+y)/8 ..... )

The above expression forms a geometric series with ratio as 2 and starting element as (x+y)/2 T(x, y) is upper bounded by Θ(x+y) as sum of infinite series is 2(x+y). It is lower bounded by (x+y)

QUESTION: 4

Consider the recurrence relation a_{1} = 8, a_{n} = 6n^{2} + 2n + a_{n-1}. Let a_{99} = k x 10^{4}. The value of K is _____ Note : This question was asked as Numerical Answer Type.

Solution:

a_{1} = 8 a_{n} = 6n^{2} + 2n + a_{n-1} a_{n} = 6[n^{2} + (n-1)^{2}] + 2[n + (n-1)] + a_{n-2} Continuing the same way till n=2, we get a_{n} = 6[n^{2} + (n-1)^{2} + (n-2)^{2} + ... + (2)^{2}] + 2[n + (n-1) + (n-2) + ... + (2)] + a_{1} a_{n} = 6[n^{2} + (n-1)^{2} + (n-2)^{2} + ... + (2)^{2}] + 2[n + (n-1) + (n-2) + ... + (2)] + 8 a_{n} = 6[n^{2} + (n-1)^{2} + (n-2)^{2} + ... + (2)^{2}] + 2[n + (n-1) + (n-2) + ... + (2)] + 6 + 2 a_{n} = 6[n^{2} + (n-1)^{2} + (n-2)^{2} + ... + (2)^{2} + **1**] + 2[n + (n-1) + (n-2) + ... + (2) + **1**] a_{n} = (n)*(n+1)*(2n+1) + (n)(n+1) = (n)*(n+1)*(2n+2) a_{n} = 2*(n)*(n+1)*(n+1) = 2*(n)*(n+1)^{2} Now, put n=99. a_{99} = 2*(99)*(100)^{2} = 1980000 = K * 10^{4} Therefore, K = 198. Thus, C is the correct choice.

QUESTION: 5

When n = 2^{2k} for some k ≥ 0, the recurrence relation

T(n) = √(2) T(n/2) + √n, T(1) = 1

evaluates to :

Solution:

Please note that the question is asking about exact solution. Master theorem provides results in the form of asymptotic notations. So we can't apply Master theorem here. We can solve this recurrence using simple expansion or recurrence tree method.

T(n) = √(2) T(n/2) + √n = √(2) [√(2) T(n/4) + √(n/2) ] + √n = 2 T(n/4) + √2 √(n/2) +√n = 2[ √2 T(n/8) + √(n/4) ]+√2 √(n/2)+√n = √(2^3) T(n/8)+ 2 √(n/4) + √2 √(n/2) +√n = √(2^3) T(n/8)+√n +√n +√n = √(2^3) T(n/(2^3))+3√n ............................................. = √(2^k) T(n/(2^k))+k√n = √(2^logn) + logn √n = √n + logn √n = √n(logn +1)

**Alternate Solution : **This question can be easily done by substitution method look: T(1)= 1; GIVEN. Now use n=2 in the given recurrence relation which gives 2*(1.414) (since value of root over 2 is 1.414) now by looking at the options use n=2 which satisfies option A.

QUESTION: 6

Standard planning algorithms assume environment to be __________.

Solution:

Standard planning algorithms assume environment to be both deterministic and fully observable. So, option (A) is correct.

QUESTION: 7

The worst-case running time of Merge sort algorithm is described by the following recurrence relation :

Given recurrence equation evaluates to -

Solution:

T(n) = 2T (n/2) + n = 2^{1} T(n/2^{1}) + 1.n [ k = 1] = 2^{k-1} T(n/2^{k-1}) + (k-1)n = 2^{k-1} (2T(n/2^{k} + n/2^{k-1}) + (k-1)n = 2^{k} T(n/2^{k}) + kn

Option (A) is Correct.

QUESTION: 8

What is the time complexity for the following C module? Assume that n>0 . int module(int n) { if (n == 1) return 1; else return (n + module(n-1)); }

Solution:

F(n) = (n + f(n-1)) → n + (n-1 + f(n-2))→ n + (n-1 + (n-2 (+...+ (n-(n-1) + f(1))) Time complexity of of code is = O(n)

QUESTION: 9

For parameters a and b, both of which are ω(1), T(n)=T(n^{1/a})+1, and T(b)=1. Then T(n) is

Solution:

Given,

T(n) = T(n^{1/a})+1, T(b) = 1

Now, using iterative method,

= T(n) = [T(n^{1/a2})+1] + 1 = [T(n^{1/a3})+1] + 2 = [T(n^{1/a4})+1] + 3 . . . = [T(n^{1/ak})+1] + (k-1) = T(n^{1/ak}) + k

Let,

→ n^{1/ak} = b → log(n^{1/ak}) = log(b) → a^{k} = log(n) / log (b) = log_{b}(n) → k = log_{a}log_{b}(n)

Therefore,

= T(n^{1/ak}) + k = T(b) + log_{a}log_{b}(n) = 1 + log_{a}log_{b}(n) = Θ(log_{a}log_{b}(n))

Option (A) is correct.

QUESTION: 10

Consider the following three functions.

f1 = 10^{n}

f2 = n^{logn}

f3 = n^{√n}

Which one of the following options arranges the functions in the increasing order of asymptotic growth rate?

Solution:

On comparing power of these given functions : f1 has n in power. f2 has logn in power. f3 has √n in power. Hence, f2, f3, f1 is in increasing order. Note that you can take the log of each function then compare.

QUESTION: 11

Consider the following recurrence relation.

Which one of the following options is correct?

Solution:

Given, recurrence relation can be written as, T(n) = T(n/2) + T(2n/5) + 7n T(n) = T((5/2)n/5) + T(2n/5) + 7n Since, sum of numerator (5/2+2 = 4.5) is less than denominator (5), so time complexity would be function itself. Hence, T(n) = Θ(7n) = Θ(n)

QUESTION: 12

What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size n?

Solution:

Arithmetic operations performed by binary search on sorted data items means computation of mid element required arithmetic operation. So it will be computed log(n) time and Hence option (C) will be correct.

QUESTION: 13

What is the value of following recurrence.

T(n) = T(n/4) + T(n/2) + cn^{2}

T(1) = c

T(0) = 0

Where c is a positive constant

Solution:

Following is the initial recursion tree for the given recurrence relation.

If we further break down the expression T(n/4) and T(n/2), we get following recursion tree.

Breaking down further gives us following

To know the value of T(n), we need to calculate sum of tree nodes level by level. If we sum the above tree level by level, we get the following series T(n) = c(n^2 + 5(n^2)/16 + 25(n^2)/256) + ....

The above series is geometrical progression with ratio 5/16 To get an upper bound, we can sum the above series for infinite terms. We get the sum as (n^2) / (1 - 5/16) which is O(n^2)

QUESTION: 14

The running time of an algorithm is represented by the following recurrence relation:

**if n <= 3 then T(n) = n **

**else T(n) = T(n/3) + cn **

Which one of the following represents the time complexity of the algorithm?

(A) (n)

(B) (n log n)

(C) (n^2)

(D) (n^2log n)

Solution:

T(n) = cn + T(n/3)

= cn + cn/3 + T(n/9)

= cn + cn/3 + cn/9 + T(n/27)

Taking the sum of infinite GP series. The value of T(n) will be less than this sum.

T(n) = cn(1/(1-1/3))

= 3cn/2

or we can say

cn = T(n) = 3cn/2

Therefore T(n) = (n)

QUESTION: 15

Consider the following recurrence. T(n) = T(√n) + θ(Log Log n) What is the value of recurrence?

(A) θ( (Log Log n)^{2})

(B) θ(Log Log n)

(B) θ(n)

(B) θ(Log Log Log n)

Solution:

Change of variables: let m = lg n. Recurrence becomes S(m) = S(m/2) + θ(lgm). Case 2 of master’s theorem applies, so T(n) = θ( (log Log n) ^ 2).

### Recurrence Relations - Discrete Mathematical Structures

Video | 57:21 min

### Recurrence Relations - Discrete Mathematical Structures

Video | 55:58 min

### Recurrence Relations(contd..) - Discrete Mathematical Structures

Video | 54:19 min

- Test: Recurrence Relations
Test | 15 questions | 35 min

- Test: Recurrence & Searching- 2
Test | 15 questions | 45 min

- Test: Relations
Test | 15 questions | 15 min

- Test: Recurrence & Searching- 1
Test | 10 questions | 30 min

- Test: Relations
Test | 10 questions | 10 min