c++ - search a Binary search tree -


I'm trying to find a name within a key, I think it's just fine. However, it has not started, maybe my code is wrong?

  In both   

main ()

(database.retrieve (name, aData)) // >
  Fixed zero recovery item (four * names, data, and adata) {cout & lt; & Lt; "& Gt; & gt; retrieve & lt; & Lt; Name & lt; & Lt; Andal & lt; & Lt; Endl; If (database. Retrev (name, adata)) // match name in both name and adata is matched & lt; & Lt; Adata & lt; & Lt; Endl; And cout & lt; & Lt; "Did not get \ n"; Cout & lt; & Lt; Endl; } Fixed zero void item (four * names) {cout & lt; & Lt; "& Gt; & gt; remove & quot; & lt; & Lt; Name & lt; & Lt; Andal & lt; & Lt; Endl; If (database. Extract (name)) cout & lt; & Lt; Name & lt; & Lt; "Deleted \ n"; And cout & lt; & Lt; Name & lt; & Lt; "Did not get \ n"; Cout & lt; & Lt; Endl; } Int main () {#ifdef _WIN32 // Request a memory leak report in the output window after main return _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif data a data; & Lt; & Lt; "Databases of great computer scientists \ n \ n"; 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); RemoveItem ("Ralston, Anthony"); DisplayDatabase (true);  

Retrieve function ...

  bool BST :: Recover (const char * key, data & amp; aata, int parent) const {For (int index = 0; index & lieutenant + message + 1; index ++) {if (item! [Index] committee {if (item [index] .instanceData == key) {aData.setName (key ); Back true; // not returning correctly}}}}  

and defined in data.cpp

  bool operator == (CONST Data & amp; D1, CONST Data & amp; d2) {return strcmp (d1.getName (), d2.getName ()) == 0; }  

So this is the bit of code inside the main () where it has not been said when I think that it should work correctly both names and the correct name in Eta which is Was found.

  Fixed zero recovery item (four * names, data, and adata) {cout & lt; & Lt; "& Gt; & gt; retrieve & lt; & Lt; Name & lt; & Lt; Andal & lt; & Lt; Endl; If (database. Retrev (name, adata)) // match name in both name and adata is matched & lt; & Lt; Adata & lt; & Lt; Endl; And cout & lt; & Lt; "Did not get \ n"; Cout & lt; & Lt; Endl; }  

You must use BST to navigate through the paste - each But do not looping items in your array, like others have said. Try something like: Recover

  bool retrieve (key, Adata) retrieve (key, Adata, guardian) real false hair if (key == Aata) returning to (key , Adata, guardian) if (key == item [parent] Knam) ADataksetName (key) and if (keys & lt; item [parent] Knam) retrieve (key, Adata, 2 * Basic + 1) Other received (key, etata, 2 * parent + 2)  

This should work well! :)


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

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

jquery - SimpleModal Confirm fails to submit form -