[알고리즘] avl트리
- 최초 등록일
- 2003.05.28
- 최종 저작일
- 2003.05
- 5페이지/ 한컴오피스
- 가격 1,500원
소개글
grand_child = child->right_child;
child->right_child = grand_child->left_child;
grand_child->left_child = child;
(*parent)->left_child = grand_child->right_child;
grand_child->right_child = *parent;
switch(grand_child->height){
/* parent의 높이가 -2, child의 높이가 1인 경우로 grand_child의 right_child는 parent의 left_child가 되고
parent는 grand_child의 right_child가 되므로 height는 0이 되고
child의 left_child인 grand_child가 없어졌으므로 height는 -1이 된다. */
case 1 : (*parent)->height = 0;
child->height = -1; break;
/* parent의 높이가 -2, child의 높이가 1인 경우이므로 grand_child의 자식노드가 없으므로
균형을 찾아간다. height는 0이 된다. */
case 0 : (*parent)->height = child->height = 0; break;
/* parent의 높이가 -2, child의 높이가 1인 경우로 grand_child의 left_child는 child의 right_child가 되고
child는 grand_child의 left_child가 되므로 height는 0이 되고
parent는 grand_child의 right_child가 되므로 height는 1이 된다. */
case -1 : (*parent)->height = 1;
child->height = 0; break;
목차
AVL트리의 구현
본문내용
/*******************************************************
File : hw6.c
Author : Donggewn Kim
Date : 05/15/03
This program was designed primarily to illustrate
the following:
- AVL Tree
********************************************************/
/**************************
Include File Section
**************************/
#include<stdio.h>
#include<stdlib.h> /* toupper */
참고 자료
없음