Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 719
  • Last Modified:

tower of hanoi

What is the algorithm for depth-first search for tower of hanoi!
0
fifi129
Asked:
fifi129
1 Solution
 
nietodCommented:
Is this a school assignment>
0
 
WynCommented:
..
0
 
KangaRooCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sunsetyangCommented:
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
 
fifi129Author Commented:
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
 
AlexVirochovskyCommented:
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
 
fifi129Author Commented:
I've already visit the sites.

Anyway, thanks to all of you
0
 
slavik022300Commented:
I'll send you the algorithm by e-mail today.
My e-mail is slv@writeme.com
0
 
nietodCommented:
Is there are reason why you can't post the solution here?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now