Posts

C program in data structure for tree

#include<stdio.h> #include<conio.h> #include<stdlib.h> struct node {  int info;  struct node *llink,*rlink; }*root=NULL; void create(); void node(struct node *q); void degree(struct node *q); void leaf(struct node *q); void interior(struct node *q); void child(struct node *q); int no,l,in,ch,p; void main() {  int n;  clrscr();  while(1)  {   printf("\n **menu**");   printf("\n 1.create a tree \n 2.count num of nodes");   printf("\n 3.degree of tree \n 4.leaf nodes \n 5.interior nodes");   printf("\n 6.childrens and parent \n 7.exit");   printf("\n enter your choice:-\t");   scanf("%d",&n);   switch(n)   {    case 1 : create();    break;    case 2 : node(root);    printf("\n\n total nodes are:-  %d",no);    break;    case 3 : degree(root);    break;    case 4 : leaf(roo...

C program in data structure for mirror of a tree

#include<stdio.h> #include<conio.h> #include<process.h> #include<stdlib.h> struct node {  int info;  struct node *llink;  struct node *rlink; }*root=NULL; void insert(); void preorder(struct node *q); void mirror(struct node *q); void main() {  int n;  clrscr();  while(1)  {   printf("\n **menu**");   printf("\n 1.insert \n 2.preorder");   printf("\n 3.mirror \n 4.exit");   printf("\n enter your choice:-");   scanf("%d",&n);   switch(n)   {    case 1 : insert();      break;    case 2 : printf("\n\n our tree in preorder \n\n");      preorder(root);      break;    case 3 :      mirror(root);      printf("\n\n mirror image is:-\n\n");      preorder(root);      break;    case 4 : exit(0);   } ...