Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

hogar Group Title

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

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. hogar Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    of course, in c

    • 2 years ago
  2. hogar Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    and possibly with recursion if possible

    • 2 years ago
  3. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    why of course in c, is c the only language in teh world? http://www.macs.hw.ac.uk/~rjp/Coursewww/Cwww/tree.html

    • 2 years ago
  4. hogar Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    this is binary search tree, not binary tree

    • 2 years ago
  5. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    maybe but it says building binary tree

    • 2 years ago
  6. hogar Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    yes, but if it is putting smaller numbers on left, and grater on right, this is binary search tree

    • 2 years ago
  7. ggmathur Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 2 years ago
  8. ecdown Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 2 years ago
  9. agdgdgdgwngo Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    http://rosettacode.org/wiki/Tree_traversal

    • 2 years ago
  10. hogar Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    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;} } } }

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.