-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRBTree.h
More file actions
44 lines (28 loc) · 666 Bytes
/
RBTree.h
File metadata and controls
44 lines (28 loc) · 666 Bytes
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
//
// Created by Андрей Москалёв on 24.10.2019.
//
#ifndef TREESPRESENTATION_RBTREE_H
#define TREESPRESENTATION_RBTREE_H
#include "Node.h"
class RBTree {
public:
Node * root;
RBTree();
void insert(int key) {
_insert(key);
}
void remove(int key) {
_remove(key);
}
private:
void _rotateLeft(Node * x);
void _rotateRight(Node * x);
void _balance_insert(Node *&x);
void _insert(int key);
void _balance_remove(Node *&x);
void _removeNode(Node *&z);
void _remove(int key);
Node * _find(int key);
int _recountHeights(Node *&p);
};
#endif //TREESPRESENTATION_RBTREE_H