[테이타 구조]n차 b트리 삽입 삭제
- 최초 등록일
- 2005.11.25
- 최종 저작일
- 2005.11
- C언어
- 가격 4,900원
소개글
b트리에서 split() 함수를 만들어 자식들은 분할 하면서 삽입 삭제하는 프로그램 입니다.
컴파일 실행환경
c 언어로 작성
본문내용
#include<stdio.h>
#include<stdlib.h>
#define M 5 // 5차 b 트리
struct record{
int numtree; // 서브트리의 개수
int key[M-1]; // 키값들
struct record *son[M]; // 자식을 가리키는 포인터
struct record *father; // 아버지를 가리킨다
};
typedef struct record NODE;
typedef NODE *NODEPTR;
int pfound = -1; //find함수가 참조
int pposition = -1; //
int ndiv2 = M/2; // 전역변수, split에서 참조
int k(NODEPTR node, int index); //단순 키값 반환 함수
int nodesearch(NODEPTR node, int key); // 해당 노드에서 자기 위치 찾는다
NODEPTR getnode(); // 공간 할당
NODEPTR insnode(NODEPTR nd, int pos, int newkey, NODEPTR newnode); // 단순 삽입 함수
NODEPTR makeBtree(NODEPTR head, int key);
void split(NODEPTR nd, int *pos, int *newkey, NODEPTR newnode, NODEPTR nd2, int *midkey); //분할
void copy(NODEPTR nd, int first, int last, NODEPTR nd2); //키값 재 분배
NODEPTR find(NODEPTR tree,int key); // 해당 키의 위치를 찾는다
NODEPTR insert(int key, NODEPTR node, int position); // 삽입함수
int index(NODEPTR nd); // 자기가 몇번째 자식인지를 안다
void traverse(NODEPTR head); // 오름차 순회 함수
NODEPTR deletion(NODEPTR head,int n); // 삭제 함수
NODEPTR delnode(NODEPTR node, int pos); // 단순 삭제함수
NODEPTR merge(NODEPTR nd); // 합병 함수
참고 자료
없음