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: .......
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.
Reg:Level Order binary tree
If u implement code for level order binary tree implementation Kindly send simple code for the same.
Thanks & Regards,