Академический Документы
Профессиональный Документы
Культура Документы
# include<stdio.h>
# include<malloc.h>
struct node
{
int info;
struct node *left_child;
struct node *right_child;
};
/* output function */
/* function main */
void main()
{
int info ;
char choice;
struct node *t = (struct node *) malloc(sizeof(struct node *));
t = null;
printf("\n input choice 'b' to break:");
choice = getchar();
while(choice != 'b')
{
printf("\n input information of the node: ");
scanf("%d", &info);
t = create_tree (info, t);
printf("\n tree is ");
output(t, 1);
printf("\n input choice 'b' to break:");
choice = getchar();
}
}
# include<stdio.h>
# include<malloc.h>
struct node
{
int info;
struct node *left_child;
struct node *right_child;
};
int depth;
void output (struct node *, int );
struct node *delet_node (struct node *, int );
struct node *create_tree (int , struct node *);
struct node * dele(struct node *, struct node *);
/* output function */
if (node == null)
{
printf("\n information does not exist in the above tree");
return (node);
}
else
{
if (info < node->info )
node->left_child = delet_node (node->left_child, info);
else
if (info > node->info )
else
/* function main */
void main()
{
int number = 0;
int info ;
char choice;
int depth;
struct node *t = (struct node *) malloc(sizeof(struct node));
t = null;
printf("\n input choice 'b' to break:");
choice = getchar();
while(choice != 'b')
{
fflush(stdin);
printf("\n input information of the node: ");
scanf("%c", &info);
t = create_tree(info, t);
number++;
fflush(stdin);
printf("\n input choice 'b' to break:");
choice = getchar();
}
fflush(stdin);
printf("\n number of elements in the list is %d", number);
printf("\n tree is \n");
output(t, 1);
printf("\n input the information to which want remove from the above tree: ");
scanf("%c", &info);
t = delet_node(t, info);
printf("\n tree after deletion of a node: ");
output(t, 1);
}
# include<stdio.h>
struct node
{
char info;
struct node *left_child;
struct node *right_child;
};
int flag = 0;
struct node *binary_tree (char *, int, int);
void output(struct node *, int );
struct node *insert_node(struct node *, char);
/* output function */
/* function main */
void main()
{
char list[100];
int number = 0;
char info ;
char choice;
struct node *t = (struct node*) malloc (sizeof(struct node));
t = null;
printf("\n input choice 'b' to break:");
choice = getchar();
while(choice != 'b')
{
fflush(stdin);
printf("\n input information of the node: ");
scanf("%c", &info);
list[number++] = info;
fflush(stdin);
printf("\n input choice 'b' to break:");
choice = getchar();
}
number --;
printf("\n number of elements in the list is %d", number+1);
t = binary_tree(list, 0, number);
printf("\n tree is \n");
output(t,1);
fflush(stdin);
printf("\n input the information of the node to which want to insert: ");
scanf("%c", &info);
t = insert_node(t, info);
printf("\n tree is \n");
output(t, 1);
}
# include<stdio.h>
struct node
{
char info;
struct node *left_child;
struct node *right_child;
};
/* output function */
/* pre-order traversal */
/* in-order traversal */
/* post-order traversal */
/* function main */
void main()
{
char list[100];
int number = 0;
char info;
char choice;
struct node *t = (struct node *) malloc(sizeof(struct node));
t = null;
printf("\n input choice 'b' to break:");
choice = getchar();
fflush(stdin);
while(choice != 'b')
{
printf("\n input information of the node: ");
scanf("%c", &info);
list[number++] = info;
fflush(stdin);
printf("\n input choice 'b' to break:");
choice = getchar();
fflush(stdin);
}
number --;
printf("\n number of elements in the list is %d", number);
t = binary_tree(list, 0, number);
output(t,1);
printf("\n pre-order traversal\n");
pre_order (t);
printf("\n in-order traversal\n");
in_order (t);
printf("\n post-order traversal\n");
post_order (t);
}