...
DSSSB PGT 2021
November 25, 2023
Operating-Systems
November 25, 2023
DSSSB PGT 2021
November 25, 2023
Operating-Systems
November 25, 2023

Data-Structures

Question 22

The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with n discs is

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
Question 22 Explanation: 
The recurrence equation for given recurrence function is
T(n) = 2T(n – 1) + 1
= 2 [2T(n – 2) + 1] + 1
= 22 T(n – 2) + 3

= 2k T( n – k) + (2k – 1)
n – k = 1
= 2n-1 T(1) + (2n-1 – 1)
= 2n-1 + 2n-1 – 1
= 2n – 1
≌ O(2n)
Correct Answer: D
Question 22 Explanation: 
The recurrence equation for given recurrence function is
T(n) = 2T(n – 1) + 1
= 2 [2T(n – 2) + 1] + 1
= 22 T(n – 2) + 3

= 2k T( n – k) + (2k – 1)
n – k = 1
= 2n-1 T(1) + (2n-1 – 1)
= 2n-1 + 2n-1 – 1
= 2n – 1
≌ O(2n)
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!