Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Library MANAGEMENT MINI PROJECT

Library MANAGEMENT MINI PROJECT

Ratings: (0)|Views: 62|Likes:
Published by Deepa Ramanujam

More info:

Published by: Deepa Ramanujam on Feb 06, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

02/06/2011

pdf

text

original

 
#include<iostream>#include<stdlib.h>#include<string.h>using namespace std;int pos;//BOOK RECORDstruct book{int bookno;char bookname[20];char author[20];int price;int no_of_copies;book *left;book *right;int height;};//STUDENT RECORDstruct student{int sid;char sname[20];char dept[20];float fine;struct card{int bookno;int ida,imon,iyr,rda,rmon,ryr;}b[2];student *left,*right;};typedef struct book *nodeptr;typedef struct student *nodeptr2;//AVL TREEclass library{public:void book_purchase(nodeptr &,nodeptr &);int bsheight(nodeptr &);nodeptr srl(nodeptr &);nodeptr srr(nodeptr &);nodeptr drl(nodeptr &);nodeptr drr(nodeptr &);int max(int,int);void book_list(nodeptr );nodeptr search(int ,nodeptr );nodeptr2 search(int ,nodeptr2 );int stock_pos(nodeptr &);void student_det(nodeptr2 &,nodeptr2 &);void displaystudent(nodeptr2 );}l;void library::book_purchase(nodeptr &x,nodeptr &p){if(p==NULL){p=new book;p->bookno=x->bookno;strcpy(p->bookname,x->bookname);strcpy(p->author,x->author);p->price=x->price;
 
p->no_of_copies=x->no_of_copies;p->left=NULL;p->right=NULL;p->height=0;}else{if(x->bookno<p->bookno){book_purchase(x,p->left);if((bsheight(p->left)-bsheight(p->right))==2){if(x->bookno<p->left->bookno)p=srl(p);elsep=drl(p);}}else if(x->bookno>p->bookno){book_purchase(x,p->right);if((bsheight(p->right)-bsheight(p->left))==2){if(x->bookno>p->right->bookno)p=srr(p);elsep=drr(p);}}}int m,n,d;m=bsheight(p->left);n=bsheight(p->right);d=max(m,n);p->height=d+1;}// insert ends //void library::student_det(nodeptr2 &t,nodeptr2 &p1){if(p1==NULL){p1=new student;p1->sid=t->sid;strcpy(p1->sname,t->sname);strcpy(p1->dept,t->dept);p1->fine=t->fine;p1->b[0].bookno=t->b[0].bookno;p1->b[1].bookno=t->b[1].bookno;p1->left=NULL;p1->right=NULL;}else if(t->sid<p1->sid)student_det(t,p1->left);else if(t->sid>p1->sid)student_det(t,p1->right); }// insert ends //void library::displaystudent(nodeptr2 p){if(p!=NULL){
 
displaystudent(p->left);{cout<<"\nstudent id:"<<p->sid;cout<<"\nstudent name:"<<p->sname;cout<<"\nstudent dept:"<<p->dept;cout<<"\n--------------------------------------------";}displaystudent(p->right);}}int library::max(int v1,int v2){return((v1>v2)?v1:v2);}int library::bsheight(nodeptr &p){int t;if(p==NULL)return -1;else{t=p->height;return t;}}nodeptr library::srl(nodeptr &p1){nodeptr p2;p2=p1->left;p1->left=p2->right;p2->right=p1;p1->height=max(bsheight(p1->left),bsheight(p1->right))+1;p2->height=max(bsheight(p2->left),p1->height)+1;return p2;}nodeptr library::srr(nodeptr &p1){nodeptr p2;p2=p1->right;p1->right=p2->left;p2->left=p1;p1->height=max(bsheight(p1->left),bsheight(p1->right))+1;p2->height=max(p1->height,bsheight(p2->right))+1;return p2;}nodeptr library::drl(nodeptr &p1){p1->left=srr(p1->left);return srl(p1);}nodeptr library::drr(nodeptr &p1){p1->right=srl(p1->right);return srr(p1);}void library::book_list(nodeptr p){if(p!=NULL){book_list(p->left);

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->