Solved

tower of hanoi

Posted on 2000-03-10
9
712 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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
 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

803 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