Printing out a tree

Hi,

I would like to print out a tree with all nodes.

For example, if the tree is:

1
2
3
4
5
6
7
        6
       / \
      2   9
     / \   \
    1   3   10
         \
          5


then the output is

1
2
3
4
6
2 9
1 3 X 10
X X X 5 X X X X


In other words, all "fake" nodes are replaced by X. Help would be much appreciated.
ok so what exactly are you looking for? what is the problem you are trying to solve? and will the tree double in the amount of numbers on each level of the tree?
If the answer to my 3rd question is yes i can help you, If not how does the tree multiply when it is going down a level?
What I am looking for is a level order printout of the tree (the text format of the tree), with all nodes that are NULL represented by an X.

The tree does multiply in the way that we must print out double the number of X's, but it does not physically multiply (the nodes are still NULL).

So, if a node is not represented in the tree, it is denoted by an X.
Last edited on
Awesome that sounds simple enough ill give you some code and ill explain it and you can fix it anyway you like
Topic archived. No new replies allowed.