-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWeek5_CI471.cpp
67 lines (55 loc) · 1.16 KB
/
Week5_CI471.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<stdio.h>
#include<conio.h>
#include<iostream>
#include<stdib.h>
using namespace std;
int main(){
}
struct rd_blk_tree_node{
enum {red,black} colour;
void *item;
rd_blk_tree_node *left, *right, *parent;
}
void left_rotate( Tree T, node x ){
node y;
y = x->right;
x->right = y->left;
if(y->left!=NULL)
y->left->parent = x;
y->parent = x->parent;
if(x->parent == NULL){
T->root = y;}else{
if(x==(x->parent)->left){
x->parent->left = y;
}else{
x->parent->right = y;
}
y->left = x;
x->parent = y;
}
void right_rotate( Tree T, node y ){
node x;
y = x->right;
x->right = y->left;
if(x->right!=NULL){
x->right->parent = y;
}
x->parent = y->parent;
if(y->parent == NULL){
T->root = x;
}else{
if(y==(y->parent)->left){
y->parent->left = x;
}else{
y->parent->right = x;
}
x->right = y;
y->parent = x;
}
}
void rd_blk_node_insert( Tree T, node x ){
}
void rd_blk_node_delete( Tree T, node x ){
}
void display_tree( Tree T ){
}