Please answer this using JsFiddlenet and Include both HTML a

Please answer this using JsFiddle.net and Include both HTML and JavaScript

Using the Wikipedia article I want you to write a computer program that calculates the number of moves necessary to solve Tower of Hanoi given a number of disks.

Tower of Hanoi https://en.wikipedia.org/wiki/Tower_of_Hanoi

You will calculate this by implementing the recursive algorithm of the tower and counting every time a block is moved. You may also want to print out the moves. Also I recommend not allowing input greater that 7 blocks - it starts getting pretty big after that.

This can easily be implemented by using your Stack from previous assignments - all you really do in this is push and pop from the stack.

Please answer this using JsFiddle.net and Include both HTML and JavaScript

Answer the following questions in the interface of your code;

1. What is the Complexity (In Big O)?

2. 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?

Solution

HTML:

<h1>Assignment, Module 6</h1>

<p>We are not going to solve Tower of Hanoi, you are simply going to write a program to demonstrate computational complexity. Using the wikipedia article I want you to write a computer program that calculates the number of moves necessary to solve Tower of Hanoi given a number of disks. Should we be concerned with concerned with the legend of the world ending when the 64 disk solution is physically solved?</p>

From my understanding of the assignment, we are to tell you how many moves it will take to solve it if a number of initial disks is given. So, in the article is says the minimum number of moves to solve any puzzle is 2^n-1 where n is the number of disks. So, my program will take a user input and apply it to this formula to get the resulting number.<br><br>

<button onclick=\"hanoiFormulaSolver()\">Give me a number!</button>
<p id=\"demo\"></p>

<br><br> <br><br>
Judging by the looks of things, it\'s gonna be a while before they solve this thing. The sun will burn out before then :P

Javascript:

function hanoiFormulaSolver(){

var hanoiInitialNumber = prompt(\"Please enter an initial number of hanoi disks.\");
  
var hanoiMinimumSolution = Math.pow(2, hanoiInitialNumber) - 1;
  
document.getElementById(\"demo\").innerHTML = hanoiMinimumSolution;
}

Please answer this using JsFiddle.net and Include both HTML and JavaScript Using the Wikipedia article I want you to write a computer program that calculates th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site