aspose file tools
The moose likes Beginning Java and the fly likes Traversing Tree of Hanoi Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Traversing Tree of Hanoi" Watch "Traversing Tree of Hanoi" New topic
Author

Traversing Tree of Hanoi

John Chong
Greenhorn

Joined: Jan 18, 2001
Posts: 16
May I know how to write a java program to traverse a binary tree in preorder such that it implement the recursive tower of hanoi?
Steve Fahlbusch
Ranch Hand

Joined: Sep 18, 2000
Posts: 491
    
    2

John,
Usually the Towers of Hanoi problem is created in such a way as the recursive traversal of the data creates a "binary tree" in code. And usually it is considered in-order.
But given a general binary tree one traverses the orders by
recrusive moves, such as:
for in-order:

for pre-order:

for post-order:

for towers of hanoi, you can create by


[This message has been edited by Steve Fahlbusch (edited February 14, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Traversing Tree of Hanoi
 
Similar Threads
Recursion
WA#2 word association
WA #1.....word association
Recursion
WA #2 ..... word association