-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBST.cpp
46 lines (43 loc) · 1011 Bytes
/
BST.cpp
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
#include "BST.h"
/*
* Returns the root node for this tree
*
* @return the root node for this tree.
*/
NodeInterface * BST::getRootNode() const
{
cout << "getRootNode"<<endl;
}
/*
* Attempts to add the given int to the BST tree
*
* @return true if added
* @return false if unsuccessful (i.e. the int is already in tree)
*/
bool BST::add(int data)
{
cout << "add"<<endl;
Node *ptr = new Node(data);
ptr->leftChild = NULL; // To test that the friend relationship works
NodeInterface *rval = ptr->getLeftChild();
long value = (long)rval;
cout << "Added "<<value<<endl;
root = ptr;
}
/*
* Attempts to remove the given int from the BST tree
*
* @return true if successfully removed
* @return false if remove is unsuccessful(i.e. the int is not in the tree)
*/
bool BST::remove(int data)
{
cout << "remove"<<endl;
}
/*
* Removes all nodes from the tree, resulting in an empty tree.
*/
void BST::clear()
{
cout << "clear"<<endl;
}