Results 1 to 2 of 2
- 12-04-2008, 01:30 AM #1
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
Level order binary tree traversal
I have inserted random number values into a binary tree and have successfully gotten it to print out in level order correctly but it prints all of them out on one line. I am trying to get it to print out each level on a separate line like
Level 1: 55
Level 2: 33 58
Level 3: .......
ect.
I figure I need to use some kind of loop that will run through and add the node values in a queue and print them out. Then I will need to remove those nodes so that the next level can be added. 2^(levelNumber - 1) I beleive is what I will need to use to figure out how many possible values could be on the row. I just need some ideas to figure out how to correctly add values to a queue print them and remove them and then add the next row's values. I'm using a Vector at the moment to hold values.
- 04-20-2009, 07:34 AM #2
Member
- Join Date
- Apr 2009
- Posts
- 1
- Rep Power
- 0
Similar Threads
-
Binary Search Tree
By michael_mke in forum New To JavaReplies: 3Last Post: 12-04-2008, 02:03 AM -
Binary Search Tree Traversal
By dch414 in forum New To JavaReplies: 2Last Post: 11-07-2008, 12:01 AM -
Can anybody help with cuncurrent binary search tree guys)
By danylo in forum Threads and SynchronizationReplies: 1Last Post: 04-23-2008, 06:22 PM -
Bidirectional Traversal with ListIterator
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 10:37 PM -
Binary Tree Implementation in Java
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 10:35 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks