binary tree questions

Pages: 12
now public part of class, not ideal :(

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

public:
    void printHelper(node<T>* root)
    {
        if(root==NULL)
        {
            return;
        }
        std::cout << root->m_val <<" ";
        printHelper(root->m_left);
        printHelper(root->m_right);
    }
    
    tree(T v)
    {
        std::cout << "tree cons" << std::endl;
        insert(v);
    }
    tree()
    {
        std::cout << "tree cons" << std::endl;
    }
    
    ~tree()
    {
        std::cout << "tree destructor" << std::endl;
        delete root;
    }
    
    void insert(T v)
    {
        if(!root)
        {
            root = new node(v);
        }
        else
        {
            PrivateInsert(v, root);
        }
    }
    
    void remove(T v)
    {
        RemoveNodePrivate(v, root);
    }
   
    bool contains(T v)
    {
        return PrivateContains(v, root);
    }
    
    void print()
    {
        printHelper(root);
    }
    
    int FindSmallest()
    {
       return FindSmallestPrivate(root);
    }
    
    int getNodeKey()
    {
        return nodeToRemoveKey;
    }
    
    void setNodeKey(T value)
    {
        nodeToRemoveKey = value;
    }
};

#endif /* tree_hpp */


What's wrong with that? Too long?
Yeah it’s too long to post all in one ☹️
Topic archived. No new replies allowed.
Pages: 12