-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBST.h
42 lines (36 loc) · 889 Bytes
/
BST.h
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
#pragma once
#include "BSTInterface.h"
#include "Node.h"
class BST : public BSTInterface {
public:
BST() { root = NULL;}
virtual ~BST() {}
//Please note that the class that implements this interface must be made
//of objects which implement the NodeInterface
/*
* Returns the root node for this tree
*
* @return the root node for this tree.
*/
NodeInterface * getRootNode() const;
/*
* 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 add(int data);
/*
* 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 remove(int data);
/*
* Removes all nodes from the tree, resulting in an empty tree.
*/
void clear();
protected:
Node *root;
};