Subscribe Us

Responsive Advertisement

Advertisement

Link representation of tree using C data structure

 

  Link representation of tree using C data structure




#include<stdio.h>

struct node

{

    int data;

    struct node *left;

    struct right *right;


};

struct node *create_node(int val)

{

    struct node *n=NULL;

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

    n->data=val;

    n->left=NULL;

    n->right=NULL;


};

int main()

{

   struct node *p,*p1,*p2;

   p=create_node(100);

   p1=create_node(200);

   p2=create_node(300);

   p->left=p1;

   p->right=p2;

    return 0;

}


Post a Comment

0 Comments