BSTERTWRT - # include DEEPAK AGRAWAL # include...

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

View Full Document Right Arrow Icon
# include <stdio.h> DEEPAK AGRAWAL # include <conio.h> SE CMPN A struct binarytree ROLL NO 03 { BST int info; struct binarytree *left; struct binarytree *right; }; struct binarytree * maketree(int a) { struct binarytree *p; p=(struct binarytree *)malloc(sizeof(struct binarytree)); p->info=a; p->left=NULL; p->right=NULL; return p; } void insert(struct binarytree **tree,int key) { struct binarytree *v,*p,*q; q=NULL; p=*tree; while(p!=NULL) { if(key==p->info) return; q=p; if (key<p->info) p=p->left; else p=p->right; } v=maketree(key); if (q==NULL) *tree=v; else if(key<q->info) q->left=v; else q->right=v; } void intrav(struct binarytree *p1) { if(p1!=NULL) { intrav(p1->left); printf("\n%d",(p1->info)); intrav(p1->right);
Background image of page 1

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

View Full DocumentRight Arrow Icon
} } void del(struct binarytree **tree,int key) { struct binarytree *rp,*s,*p,*q,*f; p=*tree; q=NULL; { q=p; if (key<p->info) p=p->left; else p=p->right; } if (p==NULL) { printf("\nNot Found"); return; } if (p->left==NULL) rp=p->right; if(p->right==NULL)
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.

This note was uploaded on 10/25/2010 for the course CMPN SEM4 taught by Professor Thakur during the Spring '07 term at University of Mumbai.

Page1 / 4

BSTERTWRT - # include DEEPAK AGRAWAL # include...

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