PDA

View Full Version : binary search tree not declared


surreal5335
07-23-2010, 04:24 AM
I am trying to create a binary search tree. My problem is I cant find any real good resources on what is required to declare it or how it works. All I can find is long pages of code that is not explained at all.

From a book I have read, thia is what I have created for it:


#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;



int main() {

int searchInt;
int treeArray[] = {35, 18, 48, 72, 60, 25};
int arraySize = sizeof(treeArray)/sizeof(int);

stree<int> t (treeArray, treeArray+arraySize);

cout << t.size();



cout << "Please enter your number to be searched in the tree: ";
cin >> searchInt;
cout << "\n";




system("PAUSE");

} // end main




Here is the errors I am getting on it:



C:\Documents and Settings\ben\Desktop\park\c++>g++ week7Prog.cpp
week7Prog.cpp: In function `int main()':
week7Prog.cpp:15: error: `stree' was not declared in this scope
week7Prog.cpp:15: error: expected primary-expression before "int"
week7Prog.cpp:15: error: expected `;' before "int"
week7Prog.cpp:17: error: `t' was not declared in this scope



I appreciate any help in the matter

oracleguy
07-23-2010, 04:50 AM
It doesn't know what the stree type is. Where is that being declared?

If you are trying to build your own binary tree from scratch Wikipedia actually has a decent amount of information on the subject.

surreal5335
07-23-2010, 05:20 AM
Thanks for the reply, so how I would go about declaring a standard binary search tree (not from scratch)? All I am trying to do is create one and check if a value is inside it or not. My book didnt really delve into the topic enough.
Do you know of any links that really explains how to declare a simple binary search tree?

surreal5335
07-23-2010, 08:04 AM
I am not really sure what your going for there, the link is incomplete or broken

oracleguy
07-23-2010, 04:26 PM
Thanks for the reply, so how I would go about declaring a standard binary search tree (not from scratch)? All I am trying to do is create one and check if a value is inside it or not. My book didnt really delve into the topic enough.
Do you know of any links that really explains how to declare a simple binary search tree?

There isn't a binary search tree in the standard C++ library. If your book was using stree, it was probably something they made and the source code for it should be on the CD that came with the book. Or on the website for the book or whatever.

I am not really sure what your going for there, the link is incomplete or broken

Say what?

surreal5335
07-24-2010, 03:19 AM
If your book was using stree, it was probably something they made and the source code for it should be on the CD that came with the book. Or on the website for the book or whatever.

lovely...Thanks, I will look into that.


Say what?

Someone new to the scene posted with a link that wasnt working properly. Seems that post was deleted