-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBST.h
More file actions
60 lines (47 loc) · 1.73 KB
/
BST.h
File metadata and controls
60 lines (47 loc) · 1.73 KB
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
/*
* File: BST.h
* Author: kim
*
* Created on November 9, 2014, 6:01 PM
*/
#ifndef BST_H
#define BST_H
#include "TreeNode.h"
class BST {
private:
TreeNode* root; // pointer to the root of tree
protected:
void search(TreeNode*& treePtr, const int& searchKey);
void insertItem(TreeNode*& treePtr, const int& newFrequency, const string& newWord);
void deleteItem(TreeNode*& treePtr, int searchKey);
void deleteNodeItem(TreeNode*& nodePtr);
void processLeftmost(TreeNode*& nodePtr, int& treeItem);
// Traversals don't need the TreeNode pointer by reference because we don't want
// to modify anything
void preorder(TreeNode* treePtr);
void inorder(TreeNode* treePtr);
void postorder(TreeNode* treePtr);
void breadthfirst(TreeNode* treePtr);
public:
// Default constructor
// Make an empty binary search tree with root equal to NULL
BST() {
root = NULL;
};
// Binary search tree operations
bool isEmpty() const; // Check if BST is empty
void searchTree(const int searchKey); // searches tree for an item
void searchTreeInsert(const int newFrequency, const string newWord); // searches tree for appropiate
// place to enter item and enters
// an item into BST
void searchTreeDelete(int searchKey); // Deletes and item from BST
// given search key
void preorderTraverse();
void inorderTraverse();
void postorderTraverse();
void breadthfirstTraverse();
void inorderTraversewithHeight();
void inorder(TreeNode* treePtr, int height);
friend class HashClass;
};
#endif /* BST_H */