Binary tree

113
Binary Tree And Traversing

description

 

Transcript of Binary tree

  • 1. #include printf("n***MENU***");#include printf("n1.CREATEn2.PRE-ORDER");#include printf("n3.IN-ORDERn4.POST-void create(struct node *); ORDERn5.EXIT");void in_order();printf("nPLease Enter the Choice...");void pre_order(); scanf("%d",&ch);void post_order();switch(ch)struct node {{case 1:root=NULL; int data; create(root);break; struct node *left,*right; case 2:pre_order();break;}*root=NULL,*New,*temp,*p,*stack[20];case 3:in_order();break;int top=-1,flag[20],item;case 4:post_order();break;char c;case 5:exit(0); default: printf("nInvalid choice...");void main() }{ }while(ch!=5); int ch,e;getch(); clrscr();} do {

2. void create(struct node *t) t = NULLNew->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)//Is It first node?if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("nDo you want add Another(y/n)..."); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); }}}}else{ New=(struct node *) malloc (sizeof (struct node)); 3. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)//Is It first node?if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("nDo you want add Another(y/n)..."); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); }}}}else{ New=(struct node *) malloc (sizeof (struct node)); 4. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)//Is It first node?if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("nDo you want add Another(y/n)..."); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root);New }}}}else{ New=(struct node *) malloc (sizeof (struct node)); 5. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data); 100struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("nDo you want add Another(y/n)..."); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100 New }}}}else{ New=(struct node *) malloc (sizeof (struct node)); 6. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("nDo you want add Another(y/n)..."); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100New }}}}else{ New=(struct node *) malloc (sizeof (struct node)); 7. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("nDo you want add Another(y/n)..."); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100New }} root}}else{ New=(struct node *) malloc (sizeof (struct node)); 8. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch);y { if(ch==y) s=t; create(t->right);create(root); 100New }} root}}else{ New=(struct node *) malloc (sizeof (struct node)); 9. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100New }} root}}else{ New=(struct node *) malloc (sizeof (struct node)); 10. void create(struct node *t) t = 100 New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else{ New=(struct node *) malloc (sizeof (struct node)); 11. void create(struct node *t)t = 100New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else{ New=(struct node *) malloc (sizeof (struct node)); 12. void create(struct node *t)t = 100New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ",t->data);if(c==l || c==L) scanf("%c",&c);l s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else{ New=(struct node *) malloc (sizeof (struct node)); 13. void create(struct node *t)t = 100New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else{ New=(struct node *) malloc (sizeof (struct node)); 14. void create(struct node *t)t = 100New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else{ New=(struct node *) malloc (sizeof (struct node)); 15. void create(struct node *t) t = NULLNew->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else{ New=(struct node *) malloc (sizeof (struct node)); 16. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else{ New=(struct node *) malloc (sizeof (struct node)); 17. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data); 50struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100 root }}s}}else 50New{ New=(struct node *) malloc (sizeof (struct node)); 18. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else 50 New{ New=(struct node *) malloc (sizeof (struct node)); 19. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else 50 New{ New=(struct node *) malloc (sizeof (struct node)); 20. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else50 New{ New=(struct node *) malloc (sizeof (struct node)); 21. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch);y { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else50{ New=(struct node *) malloc (sizeof (struct node)); 22. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else50{ New=(struct node *) malloc (sizeof (struct node)); 23. void create(struct node *t) t = 100 New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else50{ New=(struct node *) malloc (sizeof (struct node)); 24. void create(struct node *t)t = 100New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else50{ New=(struct node *) malloc (sizeof (struct node)); 25. void create(struct node *t)t = 100New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);r s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else50{ New=(struct node *) malloc (sizeof (struct node)); 26. void create(struct node *t)t = 100New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else50{ New=(struct node *) malloc (sizeof (struct node)); 27. void create(struct node *t)t = 100New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else50{ New=(struct node *) malloc (sizeof (struct node)); 28. void create(struct node *t) t = NULLNew->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else50{ New=(struct node *) malloc (sizeof (struct node)); 29. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else50{ New=(struct node *) malloc (sizeof (struct node)); 30. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data); 60struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100 root }}s}}else50 60New{ New=(struct node *) malloc (sizeof (struct node)); 31. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else50 60 New{ New=(struct node *) malloc (sizeof (struct node)); 32. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else 5060 New{ New=(struct node *) malloc (sizeof (struct node)); 33. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else50 60New{ New=(struct node *) malloc (sizeof (struct node)); 34. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch);n { if(ch==y) s=t; create(t->right);create(root); 100root }} s}}else50 60New{ New=(struct node *) malloc (sizeof (struct node)); 35. void create(struct node *t)t = NULL New->left=New->right=NULL;{ printf("nEnter the Element...");char ch;scanf("%d",&New->data);struct node *s; if(root==NULL)if(t!=NULL) root=New;{ else printf("nWhether you want to insert at{ Left or Rigth( L/R) of %d ", t->data); if(c==l || c==L) scanf("%c",&c);s->left=New; if(c==l|| c==L)else {s->right=New; s=t; create(t->left);} } printf("Do you want add Another (y/n)"); elsescanf("%c",&ch); { if(ch==y) s=t; create(t->right);create(root); 100root }}}}else50 60{ New=(struct node *) malloc (sizeof (struct node)); 36. void in_order() printf("%d ",p->data);{ p=p->right; int finish=0;} if(root==NULL) else {finish=1;printf("nTree is Empty...");return; }while(finish==0); } }100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n"); 5060 do {while(p!=NULL) { 4stack[++top]=p;3p=p->left; 2 } 1 if(top!=0)0 { top = -1finish = 0p=stack[top];top--; 37. void in_order() printf("%d ",p->data);{ p=p->right; int finish=0;} if(root==NULL) else {finish=1;printf("nTree is Empty...");return; }while(finish==0); } }100 root stack[++top]=NULL; p p=root; printf("nInorder Traversal is...n"); 5060 do {while(p!=NULL) { 4stack[++top]=p;3p=p->left; 2 } 1 if(top!=0) top 0 NULL { finish = 0p=stack[top];top--; 38. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL;p p=root; printf("nInorder Traversal is...n");5060 do {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 0 p=stack[top]; top--; 39. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n"); p5060 do {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }top1100 if(top!=0) 0 NULL{ finish = 0 p=stack[top]; top--; 40. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n"); p5060 do {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }top1100 if(top!=0) 0 NULL{ p=stack[top];finish = 0 top--; 41. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 dop NULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; top2 50 }1100 if(top!=0) 0 NULL{ finish = 0 p=stack[top]; top--; 42. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 dop NULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; top2 50 }1100 if(top!=0) 0 NULL{ finish = 0 p=stack[top]; top--; 43. void in_order() printf("%d ",p->data);{ p=p->right; int finish=0;} if(root==NULL) else {finish=1;printf("nTree is Empty...");return; }while(finish==0); } }100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n"); 5060 do p NULL {while(p!=NULL) { 4stack[++top]=p;3p=p->left; top2 50 } 1100 if(top!=0)0 NULL{finish = 0p=stack[top];top--; 44. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");p 5060 do {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }top1100 if(top!=0) 0 NULL{ finish = 0 p=stack[top]; top--; 45. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 do pNULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }top1100 if(top!=0) 0 NULL{ finish = 0 p=stack[top];50 100 top--; 46. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 do pNULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }top1100 if(top!=0) 0 NULL{ finish = 0 p=stack[top];50 100 top--; 47. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 do pNULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }top1100 if(top!=0) 0 NULL{ finish = 0 p=stack[top];50 100 top--; 48. void in_order() printf("%d ",p->data);{ p=p->right; int finish=0;} if(root==NULL) else {finish=1;printf("nTree is Empty...");return; }while(finish==0); } }100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n"); 5060 dopNULL {while(p!=NULL) { 4stack[++top]=p;3p=p->left; 2 } top1100 if(top!=0)0 NULL{finish = 0p=stack[top];50 100top--; 49. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL;p p=root; printf("nInorder Traversal is...n");5060 do {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 0 p=stack[top];50 100 top--; 50. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060p do {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 0 p=stack[top];50 100 top--; 51. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060p do {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 0 p=stack[top];50 100 top--; 52. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060p do {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 0 p=stack[top];50 100 top--; 53. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 do pNULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }top160 if(top!=0) 0 NULL{ finish = 0 p=stack[top];50 100 top--; 54. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 do pNULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }top160 if(top!=0) 0 NULL{ finish = 0 p=stack[top];50 100 top--; 55. void in_order() printf("%d ",p->data);{ p=p->right; int finish=0;} if(root==NULL) else {finish=1;printf("nTree is Empty...");return; }while(finish==0); } }100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n"); 5060 dopNULL {while(p!=NULL) { 4stack[++top]=p;3p=p->left; 2 } top160 if(top!=0)0 NULL{finish = 0p=stack[top];50 100top--; 56. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060p do {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 0 p=stack[top];50 100 top--; 57. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 dop NULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 0 p=stack[top];50 100 60 top--; 58. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 dop NULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 0 p=stack[top];50 10060 top--; 59. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 dop NULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 0 p=stack[top];50 100 60 top--; 60. void in_order() printf("%d ",p->data);{ p=p->right; int finish=0;} if(root==NULL) else {finish=1;printf("nTree is Empty...");return; }while(finish==0); } }100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n"); 5060 do p NULL {while(p!=NULL) { 4stack[++top]=p;3p=p->left; 2 } 1 if(top!=0)top0 NULL{finish = 0p=stack[top];50 100 60top--; 61. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 dop NULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 1 p=stack[top];50 100 60 top--; 62. void in_order()printf("%d ",p->data);{p=p->right; int finish=0; } if(root==NULL)else { finish=1; printf("nTree is Empty...");return; }while(finish==0); }}100 root stack[++top]=NULL; p=root; printf("nInorder Traversal is...n");5060 dop NULL {while(p!=NULL) {4 stack[++top]=p;3 p=p->left; 2 }1 if(top!=0) top0 NULL{ finish = 1 p=stack[top];50 10060 top--; 63. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n"); 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; 1 else 0 p=stack[top--]; top = -1finish = 0}} 64. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;pp=root;printf("nPreorder Traversal is...n"); 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; 1 else top0NULL p=stack[top--];}} 65. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;pp=root;printf("nPreorder Traversal is...n"); 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; 1 else top0NULL p=stack[top--];}} 66. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;pp=root;printf("nPreorder Traversal is...n"); 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; 1 else top0NULL p=stack[top--];} 100} 67. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;pp=root;printf("nPreorder Traversal is...n"); 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; 1 else top0NULL p=stack[top--];} 100} 68. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;pp=root;printf("nPreorder Traversal is...n"); 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; top1 60 else 0NULL p=stack[top--];} 100} 69. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;pp=root;printf("nPreorder Traversal is...n"); 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; top1 60 else 0NULL p=stack[top--];} 100} 70. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n"); p 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; top1 60 else 0NULL p=stack[top--];} 100} 71. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n"); p 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; top1 60 else 0NULL p=stack[top--];} 100} 72. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;}100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n");p 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; top160 else 0 NULL p=stack[top--];} 100 50} 73. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;}100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n");p 5060while(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; top160 else 0 NULL p=stack[top--];} 100 50} 74. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n"); 5060pwhile(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; 1 else top0NULL p=stack[top--];} 100 50} 75. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;} 100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n"); 5060pwhile(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; 1 else top0NULL p=stack[top--];} 100 50} 76. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;}100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n");5060pwhile(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; 1 else top0 NULL p=stack[top--];} 100 5060} 77. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;}100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n");5060pwhile(p!=NULL){ printf("%d ",p->data); if(p->right!=NULL) 4 stack[++top]=p->right; 3 if(p->left!=NULL)2 p=p->left; 1 else top0 NULL p=stack[top--];} 100 5060} 78. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;}100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n"); 50 60while(p!=NULL)pNULL{ printf("%d ",p->data); if(p->right!=NULL)4 stack[++top]=p->right;3 if(p->left!=NULL) 2 p=p->left;1 else0 p=stack[top--]; top = -1} 100 50 60} 79. void pre_order(){if(root==NULL){ printf("nTree is Empty..."); return;}100rootstack[++top]=NULL;p=root;printf("nPreorder Traversal is...n"); 50 60while(p!=NULL)pNULL{ printf("%d ",p->data); if(p->right!=NULL)4 stack[++top]=p->right;3 if(p->left!=NULL) 2 p=p->left;1 else0 p=stack[top--]; top = -1} 100 50 60} 80. void post_order(){int f;if(root==NULL){printf("nTree is Empty...");return;100root} stack[++top]=NULL;5060 p=root; printf("nPostorder Traversal is...n");4433221100top = -1 81. void post_order(){int f;if(root==NULL){printf("nTree is Empty...");return; 100 root}p stack[++top]=NULL; 5060 p=root; printf("nPostorder Traversal is...n");443322110 top0 NULL 82. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ }p stack[++top]=p->right; flag[top]=-1; 50 60}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];11 while(f==1)0 top0 NULL { printf("%d ",p->data); f=flag[top]; 83. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ }p stack[++top]=p->right; flag[top]=-1; 50 60}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1 top1 100 while(f==1)00 NULL { printf("%d ",p->data); f=flag[top]; 84. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ }p stack[++top]=p->right; flag[top]= -1;50 60}p=p->left; } if(top!=-1)44 {33 f=flag[top];-1 2 top260 p=stack[top--];1 11 100 while(f==1)00 NULL { printf("%d ",p->data); f=flag[top]; 85. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ } stack[++top]=p->right; flag[top]= -1; p 5060}p=p->left; } if(top!=-1)44 {33 f=flag[top];-1 2 top260 p=stack[top--];1 11 100 while(f==1)00 NULL { printf("%d ",p->data); f=flag[top]; 86. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ } stack[++top]=p->right; flag[top]= -1; p 5060}p=p->left; } if(top!=-1)44 {33 f=flag[top];-1 2 top260 p=stack[top--];1 11 100 while(f==1)00 NULL { printf("%d ",p->data); f=flag[top]; 87. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ } stack[++top]=p->right; flag[top]= -1; p 5060}p=p->left; } if(top!=-1)44 {1 3 top350 f=flag[top];-1 2260 p=stack[top--];1 11 100 while(f==1)00 NULL { printf("%d ",p->data); f=flag[top]; 88. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ } stack[++top]=p->right; flag[top]= -1;50 60} p NULLp=p->left; } if(top!=-1)44 {1 3 top350 f=flag[top];-1 2260 p=stack[top--];1 11 100 while(f==1)00 NULL { printf("%d ",p->data); f=flag[top]; 89. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ } stack[++top]=p->right; flag[top]= -1;50 60} p NULLp=p->left; } if(top!=-1)44 {1 3 top350 f=flag[top];-1 2260 p=stack[top--];1 11 100 while(f==1)00 NULL { printf("%d ",p->data); f=flag[top]; 90. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ } stack[++top]=p->right; flag[top]= -1;50 60} p NULLp=p->left; } if(top!=-1)44 {1 3 top350 f=flag[top];-1 2260 p=stack[top--];1 11 100 while(f==1)00 NULL { printf("%d ",p->data); f=flag[top]; 91. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ } stack[++top]=p->right; flag[top]= -1; p 5060}p=p->left; } if(top!=-1)44 {33 f=flag[top];-1 2 top260 p=stack[top--];1 11 100 while(f==1)00 NULL {f=1 printf("%d ",p->data); f=flag[top]; 92. dop=stack[top];{ top--; while(p!=NULL) } {if(f==-1)stack[++top]=p; f=1;flag[top]=1; }if(p->right!=NULL)}while(top!=-1);100root{ } stack[++top]=p->right; flag[top]= -1; p 5060}p=p->left; } if(top!=-1)44 {33 f=flag[top];-1 2 top260 p=stack[top--];1 11 100 while(f==1)00 NULL {f=1 printf("%d ",p->data); 50 f=flag[top]; 93. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1top 1 100 while(f==1)00 NULL { f = -1 printf("%d ",p->data); 50 f=flag[top]; 94. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1 top1 100 while(f==1)00 NULL { f = -1 printf("%d ",p->data); 50 f=flag[top]; 95. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1 top1 100 while(f==1)00 NULL { f = -1 printf("%d ",p->data); 50 f=flag[top]; 96. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1 top1 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 50 f=flag[top]; 97. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1 top1 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 50 f=flag[top]; 98. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1 top1 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 50 f=flag[top]; 99. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 1 2 top260 p=stack[top--];1 11 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 50 f=flag[top]; 100. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60} p NULLp=p->left; } if(top!=-1)44 {33 f=flag[top]; 1 2 top260 p=stack[top--];1 11 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 50 f=flag[top]; 101. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60} p NULLp=p->left; } if(top!=-1)44 {33 f=flag[top]; 1 2 top260 p=stack[top--];1 11 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 50 f=flag[top]; 102. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60} p NULLp=p->left; } if(top!=-1)44 {33 f=flag[top]; 1 2 top260 p=stack[top--];1 11 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 50 f=flag[top]; 103. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1 top1 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 50 f=flag[top]; 104. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1 top1 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 50 f=flag[top]; 105. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60p}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];1 1 top1 100 while(f==1)00 NULL { f=1 printf("%d ",p->data); 5060 f=flag[top]; 106. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ }p stack[++top]=p->right; flag[top]= -1;50 60}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];11 while(f==1)0top 0 NULL { f=1 printf("%d ",p->data); 5060 f=flag[top]; 107. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ }p stack[++top]=p->right; flag[top]= -1;50 60}p=p->left; } if(top!=-1)44 {33 f=flag[top]; 22 p=stack[top--];11 while(f==1)0top 0 NULL { f=1 printf("%d ",p->data); 5060 f=flag[top]; 108. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL) 100root{ } p stack[++top]=p->right; flag[top]= -1; 50 60}p=p->left; } if(top!=-1)4 4 {3 3 f=flag[top]; 2 2 p=stack[top--];1 1 while(f==1)0top0 NULL {f=1 printf("%d ",p->data); 5060 100 f=flag[top]; 109. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60} p NULLp=p->left; } if(top!=-1)4 4 {3 3 f=flag[top]; 2 2 p=stack[top--];1 1 while(f==1)0 0 {top = -1 , f = garbage printf("%d ",p->data); 5060 100 f=flag[top]; 110. dop=stack[top--];{ } while(p!=NULL) if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100root{ } stack[++top]=p->right; flag[top]= -1;50 60} p NULLp=p->left; } if(top!=-1)4 4 {3 3 f=flag[top]; 2 2 p=stack[top--];1 1 while(f==1)0 0 {top = -1 , f = garbage printf("%d ",p->data); 5060 100 f=flag[top]; 111. dop=stack[top--];{ } while(p!=NULL)if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100 root{ } stack[++top]=p->right; flag[top]= -1;50 60} pNULLp=p->left; } if(top!=-1) 4 4 { 3 3 f=flag[top];2 2 p=stack[top--]; 1 1 while(f==1) 0 0 { top = -1 , f = garbage printf("%d ",p->data); 5060100 f=flag[top]; 112. dop=stack[top--];{ } while(p!=NULL)if(f==-1) {f=1;stack[++top]=p;}flag[top]=1;}while(top!=-1);if(p->right!=NULL)100 root{ } stack[++top]=p->right; flag[top]= -1;50 60} pNULLp=p->left; } if(top!=-1) 4 4 { 3 3 f=flag[top];2 2 p=stack[top--]; 1 1 while(f==1) 0 0 { top = -1 , f = garbage printf("%d ",p->data); 5060100 f=flag[top];