Sunday, July 12, 2009

Binary tree programming in C++?

How can i make a binary tree (eg BST) using C++ pointer/reference method?





can you please give me some code.


I know that each node will have one box to store the item and two boxes to store the pointers to each of its siblings.





but i dont know how to code it... please help me.

Binary tree programming in C++?
This could be an example:





class node


{


private:


node *m_left;


node *m_rigth;


//a property that holds some value i.e. int value;


public:


//contructor


//destructor


*node get_left();


*node get_rigth();


void set_left(node * left_node);


void set_rigth(node * ritgth node);


int get_value();


void set_value(int value);


};





The members rigth and left node are of the same class node
Reply:There are plenty of educational institution that publish relevant materials in the internet, simply yahoo or google them.





Among what I found are:


http://cis.stvincent.edu/html/tutorials/...


http://math.hws.edu/eck/cs225/s03/binary...





http://cslibrary.stanford.edu/110/Binary...





HTH!

surveys

No comments:

Post a Comment