Discuss a hanoi tower recursion program


Discuss the below:

Q: It's the hanoi tower recursion program. In addition to what I have, I also need a function that:

1. tells how long my computer takes to move the disk (in seconds)

2. if someone can move 1 disk per second, how long would it take them to move 100 disc?

Both functions should be recursive#include using namespace std;

void move (int n, char source, char destination, char spare)
{
if (n<=1)
cout<<"move top disk from "<
else
{
move (n-1,source,spare,destination);
move(1,source,destination,spare);
move(n-1,spare, destination, source);
}
}
int main ()

{

const char peg1= 'A', peg2='B', peg3='C';
cout<<"this program solves the hanoi towers puzzle.\n\n";
cout<<"enter the number of disk: ";
int numDisk;
cin>>numDisk;
cout<

move(numDisk, peg1, peg2,peg3);


system ("pause");
return 0;
}

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Discuss a hanoi tower recursion program
Reference No:- TGS01936729

Now Priced at $25 (50% Discount)

Recommended (97%)

Rated (4.9/5)