Tower of Hanoi Diagram- Tower of Honoi

Video description:

In this video we will be discussing the Tower of Hanoi problem. We will start with understanding the problem statement, writing code for it in Javascript and then use the steps we get from our code to solve the problem in diagram. We will also see the recursion tree created by the function and understand the time complexity of Tower of Hanoi function. Github link to for the solution, https://github.com/hearsid/gfg-dsa-course/blob/main/Recursion/tower_of_hanoi.js

Main info

todo:

  • task Clip from 6:05 to 6:50
  • task Clip the last 10 seconds, include thank you
  • This is tree recursion, there are 7 nodes of tree for 3 disk, each will print, which traversal? Ans. In order traversal, in order traversal gives nodes in non decreasing order. Conditions:
  1. Three rods.
  2. One disks can be moved at a time.
  3. Only top disk can be moved.
  4. Disk can’t be placed on smaller disks.
  • Tell about types of recursions.
  • Base condition in recursion, every recursive function needs it.
  • debug window and chart in parallel.
  • TC: 2^n - 1 =

Mac full screen: Make app full screen, open mission control and drag other app to same window.

Content

Hello Friends, Lets understand the tower of Hanoi problem and then write the code for it.

Memoization in TOH

Given that solving Towers of Hanoi always takes 2^n - 1 steps…no, you’re not going to find a faster algorithm, because it takes O(2^n) just to print out the steps, much less compute them.

Feedback

  • Explain the problem statement by moving the disks from one tower to another.
  • Explain code more, if required break it down.
  • Show the output first, then write program to reach that output.