-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBtree.h
54 lines (39 loc) · 872 Bytes
/
Btree.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
#include <vector>
#include <stack>
using namespace std;
class Node{
public:
int nodeSize;
int nokey;
int indexSubtree = 1;
vector<int> key;
vector<Node*> subtree;
Node(int size){
nodeSize = size;
nokey = 0;
key.resize(size,0);
subtree.resize(size,0);
}
void insertKey(int key);
void deleteKey(int key);
Node* secondhalf();
int getCenter();
int getIndexSubtree();
int getKeyNumber();
void deleteIntermediate(int intermediate);
};
class BTree{
int mSize = 0;
void inorderBTInner(Node* root);
public:
Node* root;
BTree(int size){
root = new Node(size);
mSize = size;
}
void insertBT(int key);
void deleteBT(int key);
void inorderBT();
bool left = true; // bsNode가 x 노드의 왼쪽에 있는지 오른쪽에 있는지 판별하는 변수
Node* getBsNode(Node* x, Node* parent);
};