#include <stdio.h>
typedef struct AvlNode {
int data;
struct AvlNode *left_child, *right_child;
} AvlNode;
AvlNode *root;
AvlNode * rotate_LL(AvlNode *parent) {
AvlNode *child = parent->left_child;
parent->left_child = child->right_child;
child->right_child = parent;
return child;
}
AvlNode * rotate_RR(AvlNode *parent){
AvlNode *child = parent->right_child;
parent->right_child = child->left_child;
child->left_child = parent;
return child;
}
AvlNode * rotate_RL(AvlNode *parent){
AvlNode *child = parent->right_child;
parent->right_child = rotate_LL(child);
return rotate_RR(parent);
}
AvlNode * rotate_LR(AvlNode *parent){
AvlNode *child = parent->left_child;
parent->left_child = rotate_RR(child);
return rotate_LL(parent);
}
int get_height(AvlNode *node){
int height = 0;
if( node != NULL)
height = 1 + max(get_height(node->left_child),
get_height(node->right_child));
return height;
}
int get_height_diff(AvlNode *node){
if( node == NULL) return 0;
return get_height(node->left_child)
- get_height(node->right_child);
}
int main(void){
}
'이전것 > 개발' 카테고리의 다른 글
다항식 덧셈 프로그램 이중 연결리스트 (0) | 2015.05.11 |
---|---|
Wireshark_Intro_6.0 (0) | 2015.03.24 |
체이닝의 구현 (0) | 2014.11.20 |
선형조사법 (0) | 2014.11.18 |
Dijkstra's algorithm (0) | 2014.11.11 |