[자료구조]AVL트리
- 최초 등록일
- 2006.01.03
- 최종 저작일
- 2006.01
- C언어
- 가격 1,500원
소개글
자료구조론에 avl트리 알고리즘을 이용한 C++코딩 소스입니다.
실행방법은 처음에 입력값을 입력한뒤 ctrl+z를 입력시키면..
카운팅후 트리 정렬을 합니다.
컴파일 실행환경
visual c++
본문내용
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <conio.h>
typedef struct node{
char* word;
int count;
int bf;
struct node* left,*right;
} NODE; //노드 구조 선언
typedef enum Bool {false1,true1} Bool; // bool구성 함수
node* construct(node* p, char* s,Bool* h); // 트리구성 함수
void inorder(node* current); // 알파벳순 출력 함수
void inorder1(node* current); // 알파벳순 출력 함수
void main()
{
node *tree=0; // 트리초기화
char buffer[121]; //문자열 버퍼
Bool h=false1;
while(gets(buffer))
tree=construct(tree,buffer,&h); // 트리구성
printf("\n");
printf("문자열...카운터수\n");
inorder(tree); //트리출력 문자열과 카운터
printf("\nAVL tree 를 출력합니다.");
inorder1(tree); //트리출력
printf("\n");
getch();
}
node* construct(node* p, char* s, Bool* h)
{ //AVL트리 구성함수
node* p1,*p2;
int cmp; //문자열 비교 결과
if(p==0)
{
p=(node*)malloc(sizeof(node));
*h=true1;
p->word=(char*)malloc(strlen(s)+1);
참고 자료
없음