No, you need to either consult your textbook, or contact your professor if you are having issues understanding course material.I need to add this option
Code:cout<<"\n\t5) draw tree";
i nee this function
I am what I am asking is not the duty of teachers and it is a love for learning and after you try the code in the Hills for a period of weeks, decided to outsource those who are more experience than me
Is this a copy/paste from Google Translate? I'm having a hard time understanding what you are saying. Please use smaller sentences.
I say I do not want to code
I asked and you wait for answers ... But strange that I find all this criticism of you
Thank you very much consider me and did not ask for help
For something like this, you want to use a doubly-linked list and a recursive function to print it out.
Interesting, in my mind I'd think it would be possible with only the height of the tree, and a function prototyped something like printList(void *list, int level, int height)
.... maybe I'll start playing around with some C code....
Interesting, in my mind I'd think it would be possible with only the height of the tree, and a function prototyped something like printList(void *list, int level, int height)
.... maybe I'll start playing around with some C code....
Or google print binary tree ascii
When I do, this is the top hit:
http://stackoverflow.com/questions/801740/c-how-to-draw-a-binary-tree-to-the-console
It has some good discussion and analysis, and some possibly good-looking links, but oops, a promising one is dead. But maybe not completely dead yet, there's an update:
http://datastructuresblog.wordpress.com/2007/12/21/printing-binary-trees-in-ascii/
So with minimal googling, and a little reading, it looks like there's an example with code.
I actually had to write EXACTLY this (albiet in PHP and Java which made it infinitely easier, though pointers would have been infinitely more efficient) for a work project about 5 years back.
I spent about 3 months trying to conceptualize this and how to add/remove/collapse nodes on the tree and the double linked list and recursion was about the most effective method I came up with. Then, once the tree was built, I stuck a MASSIVE index on it so you could tell what level what node was on from any other node. Basically my tree had to have to ability to call any specific node "level 1" and start building a new tree from there.
It got horrible unmanageable by about the 30th level from the top. So yeah, the recursion and double linked list only worked so deep.
Why not just write out XML descriptor tags to a file as you traverse the tree. That seems pretty logical to me. It's one way MS allows the generation of Tree like views in ASP.net.
7
5 8
-1 8 9
-2 0 8 9 13
-3 3 9 10 15
-4 -2 2 4 9 11 14 16