amritansh22 / Data-Structures-and-Algorithms-in-cpp

This repository is in development phase and will soon provide you with c++ code of various data structures and algorithms
MIT License
369 stars 341 forks source link

Done with Program for Tower of Hanoi #510

Open Eureka-Viraj opened 3 years ago

Eureka-Viraj commented 3 years ago

Tower of

My Approach : Take an example for 2 disks : Let rod 1 = 'A', rod 2 = 'B', rod 3 = 'C'.

Step 1 : Shift first disk from 'A' to 'B'. Step 2 : Shift second disk from 'A' to 'C'. Step 3 : Shift first disk from 'B' to 'C'.

The pattern here is : Shift 'n-1' disks from 'A' to 'B'. Shift last disk from 'A' to 'C'. Shift 'n-1' disks from 'B' to 'C'.

for better understanding look at this image image

issue fixed #496

welcome[bot] commented 3 years ago

Thanks for opening this pull request! Please be sure that you have checked out our contributing guidelines.

amritansh22 commented 3 years ago

Please star this repository to show your support. In the meantime I am reviewing your code.