-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path69_inorder.c
More file actions
40 lines (36 loc) · 820 Bytes
/
Copy path69_inorder.c
File metadata and controls
40 lines (36 loc) · 820 Bytes
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
#include <stdio.h>
#include <stdlib.h>
struct node{
int data;
struct node* left;
struct node* right;
};
struct node* createNode(int data){
struct node *n;
n = (struct node *)malloc(sizeof(struct node));
n->data = data;
n->left = NULL;
n->right = NULL;
return n;
};
void inorder(struct node* root){
if(root!=NULL){
inorder(root->left);
printf("%d ",root->data);
inorder(root->right);
}
}
int main(){
struct node *p = createNode(4);
struct node *p1 = createNode(1);
struct node *p2 = createNode(6);
struct node *p3 = createNode(5);
struct node *p4 = createNode(2);
//Linking the root node with left and right children
p->left = p1;
p->right = p2;
p1 ->left = p3;
p1->right = p4;
inorder(p);
return 0;
}