Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# tower of hanoi

Posted on 2000-03-10
Medium Priority
716 Views
What is the algorithm for depth-first search for tower of hanoi!
0
Question by:fifi129
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 22

Expert Comment

ID: 2605145
Is this a school assignment>
0

LVL 5

Expert Comment

ID: 2605164
..
0

LVL 7

Expert Comment

ID: 2605188
Looks like it doesn't it.
Can you be a bit more precise? We don't want to make your homework, but we can help with problems you encounter while making the assignment.
0

Expert Comment

ID: 2607652
the graph describe the search:
(n,0,0)
|     \
(n-1,1,0)  (n-1,0,1)
|    \         |      \
(n-2,1,1) (n-1,0,1)(n-1,1,0) (n-2,1,1)
....................
the algorithm will look like:
move_tower(a,b,c)
{
check feasible placement,then choose one;
move_piece(1,a,b or c);//move one piece from a to b or c;
if(succeed()) return;
move_tower(a b c);
}
You need to add depth limit to the recursive calls,and to record its status so not to do the non-stop calling.Then the second level's second status,won't appear ,for it is the same as the third level's second status.
Perhaps it's wrong.
0

Author Comment

ID: 2607868
Thanks a lot
But how can i perform the backtrack
(check the moved pattern existed in its ancester or not)
(All node in the path of the tree should be unique)

Thank you

Fannie
0

LVL 14

Expert Comment

ID: 2608171
See
http://www.pangea.ca/kolar/javascript/Hanoi/HTonWebE.html
for links to web resources and(for example)
http://www.pangea.ca/kolar/javascript/Hanoi/algo.html
for fast non recursive algorithm(+source
text)
Alex
0

Author Comment

ID: 2609691

Anyway, thanks to all of you
0

Accepted Solution

slavik022300 earned 150 total points
ID: 2616283
I'll send you the algorithm by e-mail today.
My e-mail is slv@writeme.com
0

LVL 22

Expert Comment

ID: 2616326
Is there are reason why you can't post the solution here?
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [sâ€¦
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more â€¦
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
###### Suggested Courses
Course of the Month6 days, 18 hours left to enroll