create_linked_binary_tree
#include <stdio.h>
#include <malloc.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;
}
int main()
{
/*
// type karke node banana
struct node *p;
p = (struct node *)malloc(sizeof(struct node));
p->data = 1;
p->left = NULL;
p->right = NULL;
struct node *p1;
p1 = (struct node *)malloc(sizeof(struct node));
p1->data = 2;
p1->left = NULL;
p1->right = NULL;
struct node *p2;
p2 = (struct node *)malloc(sizeof(struct node));
p2->data = 4;
p2->left = NULL;
p2->right = NULL;
// node ko linke karna
p->left = p1;
p->left = p2;
*/
struct node *p = createnode(2);
struct node *p1 = createnode(2);
struct node *p2 = createnode(2);
// node ko linke karna
p->left = p1;
p->left = p2;
}
0 Comments