In order to create an algorithm for Tower of Hanoi, we must first figure out how to solve it with fewer disks, such as 1 or 2.
Algorithm:
The smaller (top) disk is first moved to the aux peg.
The larger (bottom) disk is then moved to the final peg.
The smaller disk is then transferred from the aux to the destination peg.
We recurse on the largest disk that needs to be relocated in the Towers of Hanoi solution. That is, we will create a recursive function that accepts the largest disk in the tower that we want to shift as a parameter.
Additionally, our function will accept three parameters: source, destination, and a third peg that we may utilize in the meantime to transfer the tower from one peg to another (spare).
To learn more about Tower of Hanoi here
https://brainly.com/question/13110830
#SPJ4