interesting question about tree

C

compboy

Hi can anyone print a binary tree in the way that it will look like a
tree?

so it will be like this:

50
/ \
30 70
/ \ \
20 35 100

can we do this in c without using gui as we can do this in java by
using gui?

thanks
 
V

Vladimir Oka

compboy said:
Hi can anyone print a binary tree in the way that it will look like a
tree?

I'm sure someone can.
so it will be like this:

50
/ \
30 70
/ \ \
20 35 100

Yes said:
can we do this in c without using gui as we can do this in java by
using gui?

And your C question was (asking for someone to do it all for you does
not count)?
 
C

compboy

Are you sure we can do this by just using plain <stdio.h>?
How do you do that then?
is it by pushing all the output to a stack or a queue and use it later
on?
Does anyone have an idea to help me to solve this problem?

Thanks.
 
B

Ben Pfaff

[drawing trees]
Are you sure we can do this by just using plain <stdio.h>?
How do you do that then?
is it by pushing all the output to a stack or a queue and use it later
on?
Does anyone have an idea to help me to solve this problem?

It's not that difficult. Just build up a "canvas" in memory and
then output it line by line when you've finished. See, e.g. the
tree drawing program in GNU libavl.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,966
Members
47,514
Latest member
AdeleGelle

Latest Threads

Top