{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Just look for it 2 0 its just another data collection

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: general binary search tree. 8 7 It goes where you expect it to be. So, now let's implement a BinaryTree structure BinaryTree (really binary search tree, but that's too long a title). 6 9 struct struct node; typedef node *nodePtr; struct node { void* data; nodePtr left, right; }; nodePtr root; void void void bool bool init_tree(nodePtr root); // // initialization destroy_tree(nodePtr root); // destruction Insert(nodePtr root, void* data); Locate(nodePtr root, void* data, void* fdata); Delete(nodePtr root, void* data); 5 We'll need a comparison function int TreeDataCmp(void* data1,void* data2); for relative positioning. like the linked list, the only difference is how the member functions operate. Initialize set root to 0 root Locate Set current node to be root of tree WHILE data is not at current node IF data required is in the left sub-tree subset current node to root of left sub-tree (the left child) subELSE set current node to root of right sub-tree (the right child) sub- Their outward appearance is the same. Although this is iterative, we can also write it recursive – much more usual. Here is a function which will perform the task. We...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern