데이터 구조 - 차 우 검색 트 리 의 구조
1616 단어 데이터 구조
#include
#include
#include
using namespace std;
typedef struct treenode
{
struct treenode *left;
char data;
int weight;
struct treenode *right;
}Treenode,* Treep;
int low=1,high=10;
char *R;
int *weight;
int *sw;
//
void init_tree(Treep &root)
{
root=NULL;
cout<data=R[i]; //
if(i==low) //
rt->left = NULL;
else //
SecondOptimal(rt->left, R, sw, low, i-1);
if(i==high) //
rt->right = NULL;
else //
SecondOptimal(rt->right, R, sw, i+1, high);
}//SecondOptimal
//
void pre_order(Treep &rt)
{
if(rt!=NULL)
{
cout<data<left);
pre_order(rt->right);
}
}
//
int seach_tree(Treep &rt,char key)
{
if(rt==NULL)
return 0;
else
{
if(rt->data==key)
{
return 1;
}
else
{
if(seach_tree(rt->left,key) || seach_tree(rt->right,key))
return 1; // , 1
else
return 0; // , 0
}
}
}
int main()
{
Treep root;
init_tree(root); //
R=(char *)malloc( high*sizeof(char) );
for(int i=low; i>ch;
if(seach_tree(root,ch)==1)
cout<