Question: The following code segment simulates moving n disks on the peg start to peg end through peg temp . Only one disk can be moved

The following code segment simulates moving n disks on the peg start to peg end through peg temp. Only one disk can be moved at a time. What is the time complexity (Big O) ?

moveTower( n, start, end, temp)

{

if (n ==1 )

moveOneDisk(start, end);

else

{

moveTower( n-1, start, temp, end);

moveOneDisk(start, end);

moveTower( n-1, temp, end, start);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!