I am currently working on a function that accepts the root for a binary tree and prints out the tree structure with the numbers. I want to know where do I begin. Do I need to count the height of the tree or what... I need some help....

Printable View

- 10-31-2001UnregisteredPrinting a binary tree??
I am currently working on a function that accepts the root for a binary tree and prints out the tree structure with the numbers. I want to know where do I begin. Do I need to count the height of the tree or what... I need some help....

- 10-31-2001Salem
> I want to know where do I begin.

At the root of the tree :p

> Do I need to count the height of the tree or what

That would depend on how you choose to represent the tree when you've printed it.

If its just a text dump, no formatting is required

But if it's a nice graphical thing, then more work is required. - 10-31-2001Unregistered
I want a graphically output:

example:

100

50

40

25 30

12

......and such - 10-31-2001Unregistered
that didnt come out right....cuz I guess this forum doesnt display the spaces. I want a graphically tree with the corresponding numbers.

- 10-31-2001Unregistered
i still need some help???what this printing of a tree structure.....

- 10-31-2001QuestionC
Still not too sure what your asking, but here goes...

1) The generic treeprinting programCode:`void printtree(node * tree)`

{

if (tree != NULL)

{

print (tree -> info); // Not a real command

printtree (tree -> left);

printtree (tree -> right);

}

}