Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Javascript Programing: Tower of Hanoi The classic example of a recursive solutio

ID: 3684170 • Letter: J

Question

Javascript Programing:

Tower of Hanoi

The classic example of a recursive solution to a relatively complex problem is the Tower of Hanoi https://en.wikipedia.org/wiki/Tower_of_Hanoi -

Assignment

A javascript program to demonstrate computational complexity. Using the wikipedia article; a computer program that calculates the number of moves necessary to solve Tower of Hanoi given a number of disks. Calculated by going through the recursive algorithm without making the actual moves. What is the Complexity (In Big O)? Should we be concerned with concerned with the legend of the world ending when the 64 disk solution is physically solved it it takes 2 seconds for each move.

Explanation / Answer

var callcallStack; function executeHanoi() { callStack=[]; Hanoi(diskCount, 0,2,1); moveDisk(); } function moveDisk() { if (callStack.length==0) return; var param = callStack.shift(); fromBar = param[0]; toBar = param[1]; var elem = document.getElementById(barsInfo[fromBar].disks.pop()); moveInfo = { elem: elem, fromBar: fromBar, toBar: toBar, whichPos: "top", dir: -1, // 1 or -1 tate: "up", endPos:60 } myTimer = setInterval(animateMove,speed); // Start animation }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote