visual studio로 binary search tree 만들기(display, search, insert, delete 기능포함)
- 최초 등록일
- 2014.02.03
- 최종 저작일
- 2013.11
- 9페이지/ MS 워드
- 가격 1,500원
소개글
visual studio로 binary search tree 만들기입니다. 텍스트 파일로부터 array를 받아들이고, 이를 binary search tree로 display해줍니다. search 기능을 통해 찾고자하는 숫자가 tree안에 존재하는지 아닌지 확인할 수 있습니다.
insert와 delete 기능을 통해 원하는 숫자를 tree안으로 삽입 혹은 삭제를 할 수 있습니다.
보고서 파일이기 때문에 자세한 설명이 첨부되어있습니다.
목차
1. 프로그램 소스 코드
2. 프로그램 빌드 결과
3. 프로그램 실행 결과(스크린샷으로 첨부)
4. 프로그램 실행 방법
5. 설명
본문내용
(1) Program Source Code
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_NODE 64
void tree_display();
typedef struct node *treePointer;
typedef struct node {
int data;
treePointer leftChild, rightChild;
};
int tree[MAX_NODE]; // tree in array
treePointer root; // tree in linked
int n; // number of nodes
int *search(treePointer root, int key)
{
/* return a pointer to the element whose key is k,
If there is no such node, return NULL. */
if (!root) return NULL;
if (key == root->data) return &(root->data);
if (key < root->data)
return search(root->leftChild, key);
return search(root->rightChild, key);
참고 자료
없음