Write an algorithm that accepts a binary tree as input
Answers
Answered by
0
Answer:
Answer : -
/* Header-File declaration */
#include<stdio.h>
#include<stdlib.h>
/* Structure declaration */
struct BinaryTree
{
int number;
struct BinaryTree *leftchild;
struct BinaryTree *rightchild;
};
typedef struct BinaryTree NODE;
/* Global variable declaration */
NODE *root, *child, *p;
int num, height=0, count=0;
/* Global function declaration */
void insertNode(int n);
void main()
{
char choice;
root = NULL;
while(1)
{
printf("\n Insert Node ? (Y/N)...");
scanf("%c",&choice);
if(choice == 'N')
break;
else
if(choice == 'Y')
{
printf("\n Enter the Number...");
scanf("%d",&num);
insertNode(num);
if(count > height)
{
height = count;
}
count = 0;
}
else
printf("\n\n Press Only (Y/N)");
}
printf("\n\n Height = %d",height);
}
Similar questions