검색어 입력폼

[자료구조론] - C언어 Tree,

저작시기 2013.05 |등록일 2014.05.06 한글파일한컴오피스 (hwp) | 9페이지 | 가격 800원

소개글

자료구조론

목차

1) Program source code
2) Program build output
3) Program execution(screen shot)
4) Program usage
5) Comment

본문내용

1. Tree

(1) Program Source Code

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX_NODE64

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
intn;// number of nodes

int *search(treePointer root, int key)//o
{
/* 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);
}

/* return a pointer to the element whose key is k, if there is no such element, return NULL. */
int* iterSearch(treePointer tree, int k)//0
{
while (tree)
{
if (k == tree->data) return&(tree->data);
if (k < tree->data)
{
tree = tree->leftChild;
}
else
{
tree = tree->rightChild;
}
}
return NULL
}

참고 자료

없음
다운로드 맨위로