anonymous
  • anonymous
I am looking for implementation of ordinary binary tree, not binary search tree. here is example how it should look 1 2 5 4 3 3
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
of course, in c
anonymous
  • anonymous
and possibly with recursion if possible
anonymous
  • anonymous
why of course in c, is c the only language in teh world? http://www.macs.hw.ac.uk/~rjp/Coursewww/Cwww/tree.html

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
this is binary search tree, not binary tree
anonymous
  • anonymous
maybe but it says building binary tree
anonymous
  • anonymous
yes, but if it is putting smaller numbers on left, and grater on right, this is binary search tree
anonymous
  • anonymous
When you say implementation, do you mean the creation of the tree? Or do you want to be able to search it as well? Given that you have an unordered tree, your solution will involve some form of traversal O(n). As for creating the tree, I assume you want to keep it balanced. One possible solution is modifying the BST implementation. If you assign each Node a weight (which would represent the number of nodes beneath it), traverse the tree with smaller weights.
anonymous
  • anonymous
You would have to create a node with three entries, value,pointer to left, and pointer to right. Then with that implementation you could create the population, and search algorithms.
anonymous
  • anonymous
http://rosettacode.org/wiki/Tree_traversal
anonymous
  • anonymous
i made it. implementation is based on bfs search algorithm typedef struct node { int data; struct node *right; struct node *left; }mynode; void add(mynode **root,int data){ mynode *new=malloc(sizeof(mynode)); new->data=data; new->left=NULL; new->right=NULL; mynode *queue[200]={NULL}; int head=-1; int tail=-1; mynode *current; if(*root==NULL){ *root=new; return; } else{ queue[++tail]=*root; while(head!=tail){ current=queue[++head]; if(current->left!=NULL) queue[++tail]= current->left; if(current->right!=NULL) queue[++tail]= current->right; if(current->left==NULL) { current->left=new; return;} if(current->right==NULL) {current->right=new;return;} } } }

Looking for something else?

Not the answer you are looking for? Search for more explanations.