This algorithm reads the value of number of discs and prints the move that are to be done for playing towers of hanoi.
Pre: n is a positive integer which carries the value of number of discs.
Post: prints the moves that are to be done for transferring discs in ascending order in another peg
1.initialize value of n(positive integer greater than 1)
2.moves = pow(2,disk)-1
3.if(n=1)
i) moves disk from "from" to "to"
4. end if
5. else
i)hanoi(n-1,from,aux,to)
ii) moves disc from "from" to "to''
iii) hanoi(n-i,from,aux,to)
6.end else
7. prints the moves
end towers_of_hanoi
It can be solved with or without recursion, check the attached link.
a
Hypothesis
/* tower of hanoi using recursion */ #include<stdio.h> int main(void) { unsigned int nvalue; char snvalue = 'L' , invalue = 'C' , dnvalue = 'R' ; void hanoi(unsigned int , char , char , char); printf(" enter number of disks : "); scanf("%u",&nvalue ); printf("\n\ntower of hanoi problem with %d disks \n ", nvalue )" hanoi(nvalue , snvalue , invalue , dnvalue ); printf("\n"); return 0 ; } void hanoi(unsigned n , char snd1 , char ind1 , char dnd1 ) { if(n!=0) { /* move n-1 disks from starting to intermadiate needles */ hanoi(n-1 , snd1 , dnd1 , ind1 ); /* move disk n from start to destination */ printf("move disk %d from %c to %c\n ", n , snd1 , dnd1); /* move n-1 disks from intermediate to destination needle */ hanoi(n-1 , ind1 , snd1 , dnd1 ); } }
Research Towers Of Hanoi http://en.wikipedia.org/wiki/Tower_of_Hanoi You will find your answer
An algorithm.
When solving a problem it can be beneficial to go about it in an organized fashion. Start by assessing the problem, brain storm solutions and once a solution is identified, create a detailed plan to implement the solution.
2n-1
010001010001011111100010100010101010111100110011100111000101001100 In binary
Towers of Hanoi.
For any n-disc version of the Tower of Hanoi, the optimum solution for the puzzle takes a minimum of 2n-1 moves. In the case of 6, 7, 8-sized Towers of Hanoi, the puzzle would take: 26-1 = 63, 27-1 = 127, 28-1 = 255 moves.
Putting a question mark after the name of a game or puzzle does not make it a sensible question.
1. Write mathematical analysis for recursive algorithms. Solve Tower of Hanoi Problem and analyze it.
Can I please have the steps, sketch and formula for the tower of hanoi
The Tower of Hanoi (also called the Tower of Brahma or Lucas' Tower, and sometimes pluralized) is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod.
The rental price of high ranking apartments in Hanoi is going down this year. At this time, rate of furnished 2 bedroom apartment at Sky City Towers - 88 Lang Ha is about 1000 - 1200 USD per month
I'm having the same problem. Does anyone know a solution?
Tower of Hanoi puzzle game - mathematical problem
im not sure but it could be double it plus one? if you find out can you please answer the question thanks The answer is (2^n) - 1 where n is the number of disks