-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAVL_Tree_v2.h
43 lines (38 loc) · 1.03 KB
/
AVL_Tree_v2.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
#ifndef AVL_TREE_V2_H
#define AVL_TREE_V2_H
#include <iostream>
#include <cassert>
#include <queue>
#define edl '\n'
template <class type>
class AVL_Tree_v2
{
type data{};
int height{};
AVL_Tree_v2<type> *left{};
AVL_Tree_v2<type> *right{};
int ch_height(AVL_Tree_v2<type> *node);
int update_height();
int balance_factor();
AVL_Tree_v2<type> *right_rotation(AVL_Tree_v2<type> *Q);
AVL_Tree_v2<type> *left_rotation(AVL_Tree_v2<type> *P);
AVL_Tree_v2<type> *balance(AVL_Tree_v2<type> *node);
AVL_Tree_v2<type> *min_node();
AVL_Tree_v2<type> *max_node();
void special_delete(AVL_Tree_v2<type> *child);
AVL_Tree_v2<type> *delete_node(type val, AVL_Tree_v2<type> *node);
void re_root(AVL_Tree_v2<type> *node);
void clear();
void verify();
public:
AVL_Tree_v2(type data);
~AVL_Tree_v2();
void insert(type val);
void delete_value(type val);
void level_order_traversal();
bool is_bst();
type min_value();
type max_value();
bool search(type val);
};
#endif