![]() Shift the only remaining disk from tower C to tower B.Now we are left with 3 disks in tower B that are perfectly arranged and single disk remaing in tower C.Let’s now shift the topmost disk from tower A to tower C.And shift the last disk from tower C to tower B.Now shift the first 2 disks from tower C to tower A.Shift the only disk remaining in tower A to tower B.Shift top 3 disks from tower A to tower C(Iterations Needed: 3).And then we repeat the same procedure for the remaining disks.įor example, consider the case with 4 disks, ![]() Notice that now we just need to shift the remaining N – 1 disks from tower B to tower Cīasically, we shift the disks from one tower to the second tower by taking the help of the third tower.Then shift the bottom most disk to tower C.We shift the top N – 1 disks from tower A to the tower B.And tower ‘A’ initially contains all the disks. Let’s suppose that the towers are named as ‘A’, ‘B’, and ‘C’. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |