-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBBSTree.h
51 lines (48 loc) · 1006 Bytes
/
BBSTree.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
/*
* @Description: In User Settings Edit
* @Author: your name
* @Date: 2019-09-16 15:34:29
* @LastEditTime: 2019-09-16 16:58:00
* @LastEditors: Please set LastEditors
*/
#pragma once
class BBSTree
{
private:
enum _EF
{
LH = -1,
EH = 0,
RH = 1
};
class Node
{
public:
Node *left;
Node *right;
int EF;
int data;
};
Node *root;
public:
BBSTree();
~BBSTree();
void Insert(int d);
void Delete(int d);
void PreOrder();
void InOrder();
void PostOrder();
private:
void LRotate(Node **n);
void RRotate(Node **n);
bool LBalance(Node **n);
bool RBalance(Node **n);
bool Insert(Node **n, int d, bool *taller);
void Delete(Node **n, int d);
void PreOrder(Node *n);
void InOrder(Node *n);
void PostOrder(Node *n);
void Destroy(Node *n);
int Height(Node *n);
BBSTree::Node* FindLeftMax(Node *n);
};