-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindHeightIterative.c
59 lines (48 loc) · 1.09 KB
/
FindHeightIterative.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<stdio.h>
#include<stdlib.h>
#define MAX_QUEUE_SIZE 200
typedef struct node node;
/**
* Creating a structure for a node
**/
struct node {
int data;
node *left;
node *right;
};
/**
* Helper function to create new node in the tree
**/
node* newNode(int value) {
node* newNode = (node*)malloc(sizeof(node));
newNode->data=value;
newNode->left = NULL;
newNode->right = NULL;
return newNode;
}
int getHeightIterative(node *root) {
if(root==NULL) return 0;
int height = 0;
while(root!=NULL) {
}
}
/**
* Main Driving Function
**/
void main() {
node* a = newNode(50);
a->left = newNode(30);
a->right = newNode(20);
a->left->left = newNode(10);
a->left->right = newNode(60);
a->right->left = newNode(70);
a->left->right->left = newNode(80);
// 50
// / \
// 30 20
// / \ /
// 10 60 70
// /
// 80
printf("\nHeight: %d",getHeightIterative(a));
}