Need BinaryTree code

May 14, 2011 at 4:19pm
Hi, I need to create a binary tree with linked lists.the code captures data from input and saves them in linked lists. and i am new to programming so please put all of the code. thank you
May 14, 2011 at 5:19pm
We aren't going to do your homework. Not for free, anyway..
May 14, 2011 at 6:04pm
OK sorry
can you tell me how can i input nodes, level by level?
May 14, 2011 at 7:51pm
Do you want to make a complete binary tree (a tree where every level is full) ?
Actually you could read the input into an array, and construct a tree from it easily.. Though that might not be exactly what you need to do..
May 14, 2011 at 8:15pm
no i have to create it with linked lists.
May 14, 2011 at 10:35pm
That's not what I was asking about..

Anyway, let's start from the beginning. Can you write a node class? Can you write a function to add a node to the list?
May 15, 2011 at 5:48am
sorry i forgot .no it's not a complete binary tree.
i can write the node structure

struct node{
node *left;
int data;
node *right};

but i don't know how to add a node to the list
Last edited on May 15, 2011 at 5:49am
May 15, 2011 at 6:55am
If it isn't a complete tree, how can you enter nodes level by level? You don't know how many nodes each level will have.

Are there any properties this tree should hold? Is it a binary search tree, a heap ?
May 15, 2011 at 9:20am
hmm i was wondering . (im new to c++)

Is a tree a type of list .. or can we add build a tree which contains a list at every node which has a string in it. I have this project which it kinda confusing.

Also i just wrote some code where i add a String into the tree but I cant keep adding the rest of the strings withing the file because i dont know how to move through the file.

Any help would be appreciated. :)

Thank you.
Topic archived. No new replies allowed.