-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBST.h
62 lines (45 loc) · 1.57 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// BST.h
#ifndef __BST_H__
#define __BST_H__
#include "NodeBST.h"
class BST
{
public:
BST();
~BST();
NodeBST* GetRoot() const;
bool IsEmpty() const;
void Clear();
int GetDegree() const;
int GetHeight() const;
std::string TraverseInOrder() const;
std::string TraversePreOrder() const;
std::string TraversePostOrder() const;
NodeBST* FindMin() const;
NodeBST* FindMax() const;
NodeBST* Predecessor(int id) const;
NodeBST* Successor(int id) const;
NodeBST* SearchIterative(int id) const;
NodeBST* Search(int id) const;
NodeBST* InsertIterative(int id, const std::string& data);
NodeBST* Insert(int id, const std::string& data);
bool RemoveIterative(int id);
void Remove(int id);
private:
NodeBST* m_Root;
void Destroy(NodeBST *node);
int GetDegreeInternal(const NodeBST* node) const;
std::string TraverseInOrderInternal(const NodeBST* node) const;
std::string TraversePreOrderInternal(const NodeBST* node) const;
std::string TraversePostOrderInternal(const NodeBST* node) const;
NodeBST* FindMinInternal(NodeBST* node) const;
NodeBST* FindMaxInternal(NodeBST* node) const;
NodeBST* PredecessorInternal(NodeBST* node) const;
NodeBST* SuccessorInternal(NodeBST* node) const;
NodeBST* SearchInternal(NodeBST* node, int &id) const;
NodeBST* InsertInternal(NodeBST* node, NodeBST* parent, int id, const std::string& data);
NodeBST* RemoveInternal(NodeBST* node, int id);
NodeBST* RemoveNode(NodeBST* node);
void UpdateParentChild(NodeBST* parent, const NodeBST* child, NodeBST* newChild);
};
#endif