Solved

tower of hanoi

Posted on 2000-03-10
9
709 Views
Last Modified: 2008-03-06
What is the algorithm for depth-first search for tower of hanoi!
0
Comment
Question by:fifi129
9 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2605145
Is this a school assignment>
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2605164
..
0
 
LVL 7

Expert Comment

by:KangaRoo
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

by:sunsetyang
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)
{  
 //source a,target c,b is additional:
 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:fifi129
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

by:AlexVirochovsky
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

by:fifi129
ID: 2609691
I've already visit the sites.

Anyway, thanks to all of you
0
 

Accepted Solution

by:
slavik022300 earned 75 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

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now