-
Notifications
You must be signed in to change notification settings - Fork 0
/
avl.h
41 lines (36 loc) · 823 Bytes
/
avl.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
#ifndef AVL_H
#define AVL_H
struct Node {
int key;
Node* left;
Node* right;
int height;
};
class AVL {
public:
AVL();
~AVL();
void insert(int key);
void remove(int key);
bool search(int key);
void printInorder();
int getHeight();
int getBalanceFactor();
int getMinValue();
int getMaxValue();
private:
Node* root;
Node* newNode(int key);
Node* rotateRight(Node* y);
Node* rotateLeft(Node* x);
int height(Node* node);
int balanceFactor(Node* node);
Node* insert(Node* node, int key);
Node* minValueNode(Node* node);
Node* remove(Node* node, int key);
void printInorder(Node* node);
void deleteTree(Node* node);
int minValue(Node* node);
int maxValue(Node* node);
};
#endif