-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAVL.h
More file actions
40 lines (33 loc) · 684 Bytes
/
AVL.h
File metadata and controls
40 lines (33 loc) · 684 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
#ifndef AVL_H
#define AVL_H
#include <iostream>
#include <algorithm>
#include <string>
#include <iostream>
#include "utility.h"
using namespace std;
struct node {
struct node* left;
int data;
int height;
struct node* right;
};
class AVL
{
private:
Utility utility;
int getBalanceFactor(struct node* N);
struct node* leftRotation(struct node* n);
struct node* rightRotation(struct node* n);
struct node* rightLeftRotation(struct node* n);
struct node* leftRightRotation(struct node* n);
public:
struct node* root;
// initialize root node to NULL;
AVL() {
this->root = NULL;
}
int getHeight(node* node);
struct node* insert(struct node* r, int data);
};
#endif