Binary Search Tree

how do i keep up with a binary search tree? using this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template <typename Comparable>
class BinarySearchTree{
      
        
    private:
        
        struct BinaryNode{
            Comparable element;
            BinarySearchTree<Comparable> *left;
            BinarySearchTree<Comparable> *right;
            
            BinaryNode(const Comparable & theElement, BinarySearchTree<Comparable> *leftTree, BinarySearchTree<Comparable> *rightTree) : element(theElement), left(leftTree), right(rightTree){}
        };
        
        BinaryNode *root;



every object of the tree has to be a tree not a struct. its not a tree of structs its a tree of trees but this twist makes it impossible for me to keep up with the tree... since every time i initialize a new leaf to insert, its a binary tree its self so will have its own specific value of "root" and theres no way that i can think of to have an actual variable that keeps track of the tree... every example implementation i find is a tree of structs not a tree of trees...
Topic archived. No new replies allowed.