Question: // The code must be in C #include #include #include #include struct node { int data; struct node *left; struct node *right; }; struct node*

// The code must be in C

#include

#include

#include

#include

struct node {

int data;

struct node *left;

struct node *right;

};

struct node* insert( struct node* root, int data ) {

if(root == NULL) {

struct node* node = (struct node*)malloc(sizeof(struct node));

node->data = data;

node->left = NULL;

node->right = NULL;

return node;

} else {

struct node* cur;

if(data <= root->data) {

cur = insert(root->left, data);

root->left = cur;

} else {

cur = insert(root->right, data);

root->right = cur;

}

return root;

}

}

/* you only have to complete the function given below.

node is defined as

struct node {

int data;

struct node *left;

struct node *right;

};

*/

int getHeight(struct node* root) {

// Write your code here

}

int main() {

struct node* root = NULL;

int t;

int data;

scanf("%d", &t);

while(t-- > 0) {

scanf("%d", &data);

root = insert(root, data);

}

printf("%d",getHeight(root));

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!