AVL - #include<stdio.h> #include<conio.h>...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> #include<alloc.h> #include<stdlib.h> /* RISHI AGARWAL             AVL TREE    ROLL NO 02   SE CMPN A */ int TRUE=1; struct node {   int info,bal;   int imbal;   struct node *left,*right; }; typedef struct node *nodeptr; nodeptr p,tp,q,proot; nodeptr getnode() { nodeptr r;   r=(nodeptr)malloc(sizeof(struct node));   return r; } nodeptr maketree(int x) { nodeptr r;   r=getnode();   if(r==NULL)   exit(1);   r->info=x;   r->bal=0;   r->imbal=0;   r->left=r->right=NULL;   return(r); } void setleft(nodeptr r,int x) { if(r==NULL) printf("\nVoid insertion ");   else if (r->left!=NULL) printf("\nInvalid insertion ");   else r->left=maketree(x); } void setright(nodeptr r,int x) {   if(r==NULL) printf("\nVoid insertion ");   else if (r->right!=NULL) printf("\nInvalid insertion ");   else r->right=maketree(x); } void inorder(nodeptr r) {   if(r!=NULL)   {  inorder(r->left);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
 printf("%d ",r->info);  inorder(r->right);   } } void leftrotate(nodeptr p)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

AVL - #include&lt;stdio.h&gt; #include&lt;conio.h&gt;...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online