c++ - Searching a Binary Search Tree - Array Based -


I am trying to use a key value recursively. In retrieving the function: The problem is that the index goes from 0, 1,3,7, 15 .... It is estimated to go at 0,1,3,7,8 and further I hope That has been inserted to work. I have all the assignments, prepers, all work. Can anyone help me understand this problem? I am working on this for 4 days! I think it goes from right to left. The problem is that it does not work right after going left. I'll only add functions and code, I think you will need to help me. I'm using 2 retireways to recurs ..

< Pre> bool BST :: retrieve (const char * key, data, and edata) const {recover (key, adata, guardian); If (key ==Ataata) {return true; } Other {return false; }}

Other recover

  bool BST :: recover (const char * key, data and adata, int parent) const {if ( ! Items [original] .important {if (key == item [guardian] .instanceData.getName ()) {aData.setName (key); Back true; } And if (key> lt; item [guardian] .instanceData.getName ()) // changed - now to go to o by 0,2,6, 2,5 {original = (2 * original) + 1 ; Retrieve (Key, Edata, Parents); } Other {original = (2 * original) + 2; Retrieve (Key, Edata, Parents); } // return 0; }}  

== Operator Function ..

  Bowl operator == (CONST Data & amp; D1, CONST Data & amp; D2) {Return Strump (D1 GetName (), d2.getName ()) == 0; }  

And here is one of my header files.

  #include "data.h" class BST {public: BST (int capacity = 5); // Constructor (default if no AGR has been given) BST (Const BST and stable); // copy maker ~ BST (); // Insert Disser Zero (Constant Data and Edata); Remove hair (cons four * key); Recover Bull (const char * key, data and adata) const; Zero performance order (ostream and ow) console; Zero Displayproducer (Ostream and Out) Constant; Zero performance INOrder (ostream and outside) const; Zero Display Post Order (Orstream & amp; Out) CONST; Int getSize (zero) const; Private: integer size; Integer maximum; Ing original; Zero extension (); Structure object {Bull Blank; Data example data; Boole's Leaf; }; Item * items; Enter zero (int index, content data and adata); Zero DisplayHands (Ostream and Out) CONST; Zero BST :: displayPreOrder (std :: ostream & outside, int parent) const; Zero BST :: displayInOder (std :: ostream & ou, int parent) const; Zero BST :: displayPostOrder (std :: ostream & outside, int parent) const; Bool BST :: Recover (const char * key, Data & amp; EDATA, INS original) const; Zero objects perforated (hustle and outside, integer shape) const; }; #endif // BST_H  

part of the main () function ..

  database.insert (data ("Ralston, Anthony"); Database.insert (Data ("Liang, Lee")); Database.insert (Data ("Jones, Doug")); Database.insert (Data ("Goble, Colin")); Database.insert (Data ("Nith, Donald"); Database.insert (Data ("Kay, Alan")); Database.insert (Data ("von Neumann, John")); Database.insert (Data ("Tryboboff, Michael"); Database.insert (Data ("Turing, Allen")); DisplayDatabase (true); Recovered item ("Tryboboff, Michael", Edata); Recovered item ("Kaya, Danny", Edata); // Call Search Function ..  

and

  Bull Operator & lt; (Cost Data & amp; D1; Constant & amp; D2) {Return Struggle (d1.getName (), d2.getName ()) & lt; 0; }  

this 0,1,3,7,8

Why are you expecting this behavior? This is not exactly "binary" search 7 left child will be 15, the right child will be 16. 3 is the perfect child of 3.

Your code looks correct. Your results look right, your expectations appear to be defective.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -