retagged by
2,412 views

1 Answer

3 votes
3 votes
TOH(n, x, y, z)
{
   if (n >= 1)
   {
      // put (n-1) disk to z by using y-----------T(n-1)
      TOH((n-1), x, z, y)
   
       // move larger disk to right place-----------------only one disk move at a time.
       move:x-->y
     
      // put (n-1) disk to right place 
      TOH((n-1), z, y, x)-------------T(n-1)
   }
}

  Recurrence relation :   T(n) = 2T(n-1) +1

  Hence option D is correct.

Answer:

Related questions

4 votes
4 votes
1 answer
1
admin asked Mar 31, 2020
1,850 views
The number of unused pointers in a complete binary tree of depth $5$ is:$4$$8$$16$$32$
4 votes
4 votes
4 answers
2
admin asked Mar 31, 2020
2,007 views
A ________ is a linear list in which insertions and deletions are made to from either end of the structure.Circular queue.Priority queue.Stack.Dequeue.
3 votes
3 votes
2 answers
3
admin asked Mar 31, 2020
2,549 views
Which of the following is the correct order of evaluation for the below expression? $z=x+y^*z/4\%2-1$$^*/\%+-=$$=^*/\%+-$$/^*\%-+=$$^*\% /-+=$
3 votes
3 votes
1 answer
4
admin asked Mar 31, 2020
887 views
What data structures is used for depth first traversal of a graph?QueueStackListNone of the above