-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathbst_simple.h
More file actions
45 lines (39 loc) · 1.37 KB
/
Copy pathbst_simple.h
File metadata and controls
45 lines (39 loc) · 1.37 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
#include <queue>
#ifndef PROJECT_BINARY_SEARCH_TREE_H
#define PROJECT_BINARY_SEARCH_TREE_H
namespace jw {
struct BSTNode {
int data;
BSTNode* left;
BSTNode* right;
};
// Returns a new node for our BST
BSTNode* GetNewNode(int value);
// Returns true if given value is in our tree
bool Search(BSTNode* node, int value);
// Frees memory allocated for the tree.
void DeleteTree(BSTNode* node);
// Returns the minimum value stored in the tree,
// or -1 if tree is empty
int GetMin(BSTNode* node);
// Returns the maximum value stored in the tree,
// or -1 if tree is empty
int GetMax(BSTNode* node);
// Returns height of the tree, 0 if empty
int GetHeight(BSTNode* node);
// Print out the items in the tree in level order
void PrintBFS(BSTNode* node);
// Print out the items in the tree in order (inorder)
void PrintInOrder(BSTNode* node);
// Returns true if tree is a binary search tree
bool IsBinarySearchTree(BSTNode* node);
// Returns true if all items in the given tree are between the given values
bool IsBetween(BSTNode* node, int min, int max);
// Delete a specific node from the tree
BSTNode* DeleteValue(BSTNode* node, int value);
// Returns the node in the tree with the minimum value
BSTNode* GetMinNode(BSTNode* node);
// Returns the in-order successor of the given value
BSTNode* GetSuccessor(BSTNode* node, int value);
} // namespace jw
#endif // PROJECT_BINARY_SEARCH_TREE_H