6.3k views
1 vote
The efficinecy for solving the towers of hanoi problem recursively

A.O(n2)

B. O(2n)

C.O(logn)

D.O(n)

User Pronab
by
6.5k points

1 Answer

2 votes

Answer:

B.O(2n)

Step-by-step explanation:

The time complexity of solving towers of hanoi problem recursively is O(2n) because there are two recursion calls in the solution of tower of hanoi.First recursive call to move n-1 disks to from source to helper then the user moves nth disk from source to destination after that recursion moves n-1 disks from helper to destination using source as helper rod.So each recursive call make two more recursive call this makes the time complexity be O(2n).

User Edward Van Kuik
by
6.1k points