Search Preview
World of C Programming: DSA Lab
world-of-c-programming.blogspot.inThis is an try to put the solutions of all problems related to C and C++. Labs: DSA, DAA, OS, Graphics, Compiler, Network. Extra: PROBLEMS, FORUM.
.in > world-of-c-programming.blogspot.in
SEO audit: Content analysis
Language | Error! No language localisation is found. | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Title | World of C Programming: DSA Lab | ||||||||||||||||||||||||||||||||||||
Text / HTML ratio | 28 % | ||||||||||||||||||||||||||||||||||||
Frame | Excellent! The website does not use iFrame solutions. | ||||||||||||||||||||||||||||||||||||
Flash | Excellent! The website does not have any flash contents. | ||||||||||||||||||||||||||||||||||||
Keywords cloud |
void case = return int cout<< Lab bs_nodeptr Enter break Sharma s_node delete cout< |
||||||||||||||||||||||||||||||||||||
Keywords consistency |
|
||||||||||||||||||||||||||||||||||||
Headings |
|
||||||||||||||||||||||||||||||||||||
Images | We found 21 images on this web page. |
SEO Keywords (Single)
Keyword | Occurrence | Density |
---|---|---|
void | 73 | 3.65 % |
case | 56 | 2.80 % |
= | 46 | 2.30 % |
return | 46 | 2.30 % |
int | 43 | 2.15 % |
cout<< | 34 | 1.70 % |
Lab | 29 | 1.45 % |
bs_nodeptr | 22 | 1.10 % |
Enter | 19 | 0.95 % |
break | 18 | 0.90 % |
Sharma | 17 | 0.85 % |
s_node | 16 | 0.80 % |
delete | 15 | 0.75 % |
cout<13 |
0.65 % |
|
struct | 13 | 0.65 % |
== | 12 | 0.60 % |
include | 12 | 0.60 % |
DSA | 12 | 0.60 % |
Element | 12 | 0.60 % |
operations | 11 | 0.55 % |
SEO Keywords (Two Word)
Keyword | Occurrence | Density |
---|---|---|
break case | 13 | 0.65 % |
DSA Lab | 12 | 0.60 % |
else if | 11 | 0.55 % |
Mangi Lal | 9 | 0.45 % |
Lal Sharma | 9 | 0.45 % |
at 11292012 | 8 | 0.40 % |
Turbo c | 8 | 0.40 % |
FacebookShare to | 8 | 0.40 % |
to FacebookShare | 8 | 0.40 % |
Posted by | 8 | 0.40 % |
Labels DSA | 8 | 0.40 % |
by Mangi | 8 | 0.40 % |
cout<< The | 8 | 0.40 % |
TwitterShare to | 8 | 0.40 % |
Pinterest Labels | 8 | 0.40 % |
compiler Turbo | 8 | 0.40 % |
to Pinterest | 8 | 0.40 % |
c author | 8 | 0.40 % |
Mangilal Sharma | 8 | 0.40 % |
Sharma at | 8 | 0.40 % |
SEO Keywords (Three Word)
Keyword | Occurrence | Density | Possible Spam |
---|---|---|---|
Mangi Lal Sharma | 9 | 0.45 % | No |
Lal Sharma at | 8 | 0.40 % | No |
Sharma at 11292012 | 8 | 0.40 % | No |
by Mangi Lal | 8 | 0.40 % | No |
Posted by Mangi | 8 | 0.40 % | No |
compiler Turbo c | 8 | 0.40 % | No |
Turbo c author | 8 | 0.40 % | No |
comments Email ThisBlogThisShare | 8 | 0.40 % | No |
Email ThisBlogThisShare to | 8 | 0.40 % | No |
ThisBlogThisShare to TwitterShare | 8 | 0.40 % | No |
to TwitterShare to | 8 | 0.40 % | No |
TwitterShare to FacebookShare | 8 | 0.40 % | No |
to FacebookShare to | 8 | 0.40 % | No |
FacebookShare to Pinterest | 8 | 0.40 % | No |
to Pinterest Labels | 8 | 0.40 % | No |
c author Mangilal | 8 | 0.40 % | No |
author Mangilal Sharma | 8 | 0.40 % | No |
Labels DSA Lab | 8 | 0.40 % | No |
cin>>choice switchchoice case | 7 | 0.35 % | No |
cout<<\n\t\t Enter Your | 7 | 0.35 % | No |
SEO Keywords (Four Word)
Keyword | Occurrence | Density | Possible Spam |
---|---|---|---|
to FacebookShare to Pinterest | 8 | 0.40 % | No |
comments Email ThisBlogThisShare to | 8 | 0.40 % | No |
FacebookShare to Pinterest Labels | 8 | 0.40 % | No |
compiler Turbo c author | 8 | 0.40 % | No |
Turbo c author Mangilal | 8 | 0.40 % | No |
to TwitterShare to FacebookShare | 8 | 0.40 % | No |
ThisBlogThisShare to TwitterShare to | 8 | 0.40 % | No |
Email ThisBlogThisShare to TwitterShare | 8 | 0.40 % | No |
Posted by Mangi Lal | 8 | 0.40 % | No |
by Mangi Lal Sharma | 8 | 0.40 % | No |
Mangi Lal Sharma at | 8 | 0.40 % | No |
Lal Sharma at 11292012 | 8 | 0.40 % | No |
c author Mangilal Sharma | 8 | 0.40 % | No |
TwitterShare to FacebookShare to | 8 | 0.40 % | No |
Your Choice= cin>>choice switchchoice | 7 | 0.35 % | No |
am No comments Email | 7 | 0.35 % | No |
cout<<\n\t\t Enter Your Choice= | 7 | 0.35 % | No |
Enter Your Choice= cin>>choice | 7 | 0.35 % | No |
to Pinterest Labels DSA | 7 | 0.35 % | No |
Pinterest Labels DSA Lab | 7 | 0.35 % | No |
Internal links in - world-of-c-programming.blogspot.in
World of C Programming: Welcome
World of C Programming: C basic lab
World of C Programming: C++ basic lab
World of C Programming: DSA Lab
World of C Programming: DAA Lab
World of C Programming: OS Lab
World of C Programming: Graphics Lab
World of C Programming: Compiler Lab
World of C Programming: Network Lab
World of C Programming: PROBLEMS
World of C Programming: FORUM
World-of-c-programming.blogspot.in Spined HTML
World of C Programming: DSA Lab World of C Programming This is a try to put the solutions of each possible problem related to C and C++. You can find here C vital lab, C++ vital Lab, Data Structure Lab, DAA Lab, Operating System Lab, Graphics Lab, Compiler Lab, Network Lab, and other problems. Pages Home Welcome C vital lab C++ vital Lab DSA Lab DAA Lab OS Lab Graphics Lab Compiler Lab Network Lab PROBLEMS FORUM Showing posts with label DSA Lab. Show all posts Showing posts with label DSA Lab. Show all posts Thursday, 29 November 2012 Ticket window - Program Using Queue /*Ticket window - Program Using Queue compiler- Turbo c++ author- Mangilal Sharma --------------------------------------------------------*/ #include <iostream.h> #include <conio.h> #include <stdlib.h> matriculation ticket { private: int q[5]; int front, rear, n; //n..to store number of elements public: void enqueue(int); void ticketchecker(); void print(); int isempty(); void queuebuilder(); ticket(); }; void ticket::enqueue(int a) { q[rear] = a; rear++; n++; if (rear == 5) rear = 0; cout<<""<<a<<" Is Enqeueued....."<<endl; } void ticket::ticketchecker() { clrscr(); int not,rt; if ( !isempty() ) { not = q[front]; if (not > 2) { rt = not - 2; if ( rt > 0 ) { enqueue(rt); front++; cout<<""<<not<<"# Tickets were demanded. \n2 Tickets aregiven.\nEnqueued then for next go to get remaining #"<<rt<<"Tickets"<<endl; } else if ( rt <= 0 ) front++; n--; } else if ( not <= 2 ) { front++; n--; cout<<""<<not<<"# tickets are given...."<<endl; } } else cout<<"!!! NO REQUEST IN THE QUEUE " <<endl; getch(); clrscr(); return; } void ticket::print() { clrscr(); int i = front; if ( n > 0 ) { cout<<"REQUESTS ENQUEUED ARE :" ; do { cout<<q[i]<<" "; i++; if ( i == 5 ) i = 0; } while ( i != rear ); } else cout<<"NO REQUEST IN QUEUE...QUEUE IS EMPTY "; getch(); clrscr(); return; } int ticket :: isempty() { if ( n == 0 ) return 1; else return 0; } //This Function takes input from the user and shows Queue graphically void ticket::queuebuilder() { int tickets, z = 0, i = 0, x = 20, y = 10, h = 17; char c; cout<<"Enter number of tickets to purchase... "<<endl; while (!(c == 'E' || c == 'e')) { if ( z > 4) { gotoxy(5,15); cout<<" ERROR!!! Queue Size Violation...Exiting Now "<<endl; getch(); clrscr(); return; } else { cout<<"Enter : "; cin>>tickets; enqueue(tickets); z++; gotoxy(17,10); cout<<"->"; gotoxy(20,9); cout<<"----------------------------------"; gotoxy(x,y); cout<<q[i]; x+=4; gotoxy(20,11); cout<<"----------------------------------"; gotoxy(5,15); cout<<"PRESS C/c to CONTINUE E/e to END: "; cin>>c; h += 6; i++; } gotoxy(1,2); } return; } ticket::ticket() { n = rear = front = 0; int b; do { clrscr(); gotoxy(15,5); cout<<"Press 1................ENTER NO OF TICKETS"; gotoxy(15,8); cout<<"Press 2................TICKET CHECKER"; gotoxy(15,11); cout<<"Press 3................ALL TICKET REQUESTS"; gotoxy(15,14); cout<<"Press 4................MAIN PAGE"; gotoxy(15,17); cout<<"Press 5................EXIT FROM PROGRAM"; gotoxy(15,20); cout<<"NOW ENTER : "; cin>>b; switch(b) { case 1: clrscr();queuebuilder();break; case 2: ticketchecker();break; case 3: print();break; case 4: return; case 5: exit(1); default: cout<<"\n\t\tWrong Choice, Enter Again\n"; } } while(1); } /*=========================19Nov.,2010=============================*/ Posted by Mangi Lal Sharma at 11/29/2012 10:24:00 am No comments: Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: C++ vital lab, DSA Lab Spars matrix operations /*A program to empelement spars matrix operations. compiler- Turbo c++ author- Mangilal Sharma --------------------------------------------------------*/ #include <iostream.h> #include <conio.h> #include <stdlib.h> matriculation spars { private: int m[4][4],i,j,choice; public: void usm(); void lsm(); void tdsm(); spars(); }; void spars::usm() { cout<<"Enter the elements for upper sparce matrix:\n"; for(i=0;i<3;i++) { for(j=0; j<3; j++) if(i<j) m[i][j]=0; else cin>>m[i][j]; } cout<<"\n\nUpper sparce matrix is:\n"; for(i=0;i<3;i++) { for(j=0; j<3; j++) cout<<m[i][j]<<"\t";cout<<"\n"; } } void spars::lsm() { cout<<"\n\nEnter the elements for lower sparce matrix:\n"; for(i=0;i<3;i++) { for(j=0; j<3; j++) if(i>j) m[i][j]=0; else cin>>m[i][j]; } cout<<"\n\nLower sparce matrix is:\n"; for(i=0;i<3;i++) { for(j=0; j<3; j++) cout<<m[i][j]<<"\t";cout<<"\n"; } } void spars::tdsm() { cout<<"\n\nEnter the elements for tridiogonal sparce matrix:\n"; for(i=0;i<4;i++) { for(j=0; j<4; j++) if(i<j-1||j<i-1) m[i][j]=0; else cin>>m[i][j]; } cout<<"\n\nTridiogonal sparce matrix is:\n"; for(i=0;i<4;i++) { for(j=0; j<4; j++) cout<<m[i][j]<<"\t"; cout<<"\n"; } } spars::spars() { do { cout<<"\n\t\t\tSPARS MATRIX\n"; cout<<"\t\t1. Upper sparce matrix\n"; cout<<"\t\t2. Lower sparce matrix\n"; cout<<"\t\t3. Tridiogonal sparce matrix\n"; cout<<"\t\t4. To Main page\n"; cout<<"\t\t5. To Exit from Program\n"; cout<<"\n\t\t Enter Your Choice= "; cin>>choice; switch(choice) { case 1: usm();break; case 2: lsm();break; case 3: tdsm();break; case 4: return; case 5: exit(1); default:cout<<"\n\t\tWrong Choice, Enter Again\n"; } }while(1); } /*=========================3Nov.,2010=============================*/ Posted by Mangi Lal Sharma at 11/29/2012 10:21:00 am No comments: Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: DSA Lab Singly Linked List operations /*Program to impelement Singly Linked List operations compiler- Turbo c++ author- Mangilal Sharma --------------------------------------------------------*/ #include <process.h> #include <conio.h> #include <iostream.h> matriculation singly { struct s_node { int data; s_node *link; }*p; public: void inslast(int); void insbeg(int); void insnext(int,int); void delelement(int); void delbeg(); void dellast(); void disp(); int search(int); singly(); ~singly(); //destructor that deallocate the memory adderess }; void singly::inslast(int x) { s_node *q,*t; if(p==NULL) { p=new s_node; p->data=x; p->link=NULL; } else { q=p; while(q->link!=NULL) q=q->link; t=new s_node; t->data=x; t->link=NULL; q->link=t; } cout<<" Inserted successfully at the end...\n"; disp(); } void singly:: insbeg(int x) { s_node *q; q=p; p=new s_node; p->data=x; p->link=q; cout<<" Inserted successfully at the begining...\n"; disp(); } void singly::delelement(int x) { s_node *q,*r; q=p; if(q->data==x) { p=q->link; delete q; return; } r=q; while(q!=NULL) { if(q->data==x) { r->link=q->link; delete q; return; } r=q; q=q->link; } cout<<" Element u entered "<<x<<" that is not found.."; } void singly:: delbeg() { cout<<" The list surpassing deletion:"; disp(); s_node *q; q=p; if(q==NULL) { cout<<" No data is present.."; return; } p=q->link; delete q; return; } void singly:: dellast() { cout<<" The list surpassing deletion:"; disp(); s_node *q,*t; q=p; if(q==NULL) { cout<<" There is no data in the list..."; return; } if(q->link==NULL) { p=q->link; delete q; return; } while(q->link->link!=NULL) q=q->link; q->link=NULL; return; } singly::~singly() { s_node *q; if(p==NULL) return; while(p!=NULL) { q=p->link; delete p; p=q; } } void singly::disp() { s_node *q; q=p; if(q==NULL) { cout<<" No data is in the list.."; return; } cout<<" The items present in the list are :"; while(q!=NULL) { cout<<" "<<q->data; q=q->link; } } void singly::insnext(int value,int position) { s_node *temp,*temp1; temp=p; if(temp1==NULL) { temp1= new s_node; temp1->data=value; temp1->link=NULL; p=temp1; return; } for(int i=0;((i<position)&&(temp->link!=NULL)) ;i++) { if(i==(position-1)) { temp1= new s_node; temp1->data= value; temp1->link=temp->link; temp->link=temp1; } temp=temp->link; } cout<<" Inserted successfully at the position...\n"<<position; disp(); } int singly::search(int value) { s_node *temp; temp=p; int position=0; while(temp!=NULL) { if(temp->data==value) return position+1; else { temp=temp->link; position=position+1; } } cout<<" Element "<<value<<" not found"; return 0; } singly::singly() { int v,p,ps,choice; p=NULL; while(1) { cout<<"\n\t\tOperations on linked List..\n"; cout<<"\t\t1. To Insert an Element in linked list\n"; cout<<"\t\t2. To Delete an Element from linked list\n"; cout<<"\t\t3. ToExhibitthe Elements of linked list\n"; cout<<"\t\t4. To Search an element\n"; cout<<"\t\t5. To Main menu\n"; cout<<"\t\t6. To Exit from Programme\n"; cout<<"\n\t\t Enter Your Choice= "; cin>>choice; switch(choice) { case 1: cout<<"1.Insertion at begining\n2.Insertion at the end\n"; cout<<"3.Insertion without the mentioned position\n"; cout<<" Enter ur choice:"; cin>>ps; cout<<" Enter the value to insert:"; cin>>v; switch(ps) { specimen 1:insbeg(v);break; specimen 2:inslast(v);break; specimen 3:cout<<" Enter the position to insert the value:"; cin>>p; insnext(v,p);break; default:cout<<" The nomination is invalid";return; }break; case 2: cout<<"1.Delete the first element\n2.Delete the last element\n"; cout<<"3.Enter the element to delete from the list\n"; cout<<" Enter ur choice:"; cin>>ps; switch(ps) { specimen 1:delbeg(); cout<<" The list without deletion:";disp();break; specimen 2:dellast(); cout<<" The list without deletion:";disp();break; specimen 3:disp(); cout<<" Enter the element to delete:"; cin>>v; delelement(v); cout<<" The list without deletion:";disp();break; default: cout<<" The option is invalid...";break; }break; case 3: disp();break; case 4: disp(); cout<<" Enter the element to search:"; cin>>v; cout<<" The position of the element "<< v<<" is "<<search(v); getch();break; case 5:return; case 6:exit(1); default:cout<<" The option is invalid...";return; } } } /*=========================9Nov.,2010=============================*/ Posted by Mangi Lal Sharma at 11/29/2012 10:20:00 am No comments: Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: DSA Lab Binary Search tree (BST) operations /*Binary Search tree with insertion, deletion.....processes compiler- Turbo c++ author- Mangilal Sharma --------------------------------------------------------*/ # include <iostream.h> # include <stdlib.h> # include <conio.h> struct bs_node { int element; bs_node *left; bs_node *right; int height; }; typedef struct bs_node *bs_nodeptr; matriculation bst { public: bst(); void insert(int,bs_nodeptr &); void del(int,bs_nodeptr &); int deletemin(bs_nodeptr &); void find(int,bs_nodeptr &); bs_nodeptr findmin(bs_nodeptr); bs_nodeptr findmax(bs_nodeptr); void copy(bs_nodeptr &,bs_nodeptr &); void makeempty(bs_nodeptr &); bs_nodeptr bs_nodecopy(bs_nodeptr &); void preorder(bs_nodeptr); void inorder(bs_nodeptr); void postorder(bs_nodeptr); int bsheight(bs_nodeptr); bs_nodeptr srl(bs_nodeptr &); bs_nodeptr drl(bs_nodeptr &); bs_nodeptr srr(bs_nodeptr &); bs_nodeptr drr(bs_nodeptr &); int nobs_nodes(bs_nodeptr); int maxx(int value1,int value2) { return ((value1 > value2) ? value1 : value2); } }; void bst::insert(int x,bs_nodeptr &p) { if (p == NULL) { p = new bs_node; p->element = x; p->left=NULL; p->right = NULL; p->height=0; if (p==NULL) cout<<"Out of Space"; } else { if (x<p->element) { insert(x,p->left); if ((bsheight(p->left) - bsheight(p->right))==2) { if (x < p->left->element) p=srl(p); else p = drl(p); } } else if (x>p->element) { insert(x,p->right); if ((bsheight(p->right) - bsheight(p->left))==2) { if (x > p->right->element) p=srr(p); else p = drr(p); } } else cout<<"Element Exists"; } int m,n,d; m=bsheight(p->left); n=bsheight(p->right); d=maxx(m,n); p->height = d + 1; } bs_nodeptr bst::findmin(bs_nodeptr p) { if (p==NULL) { cout<<"Empty Tree"; return p; } else { while(p->left !=NULL) p=p->left; return p; } } bs_nodeptr bst::findmax(bs_nodeptr p) { if (p==NULL) { cout<<"Empty Tree"; return p; } else { while(p->right !=NULL) p=p->right; return p; } } void bst::find(int x,bs_nodeptr &p) { if (p==NULL) cout<<"Element not found"; else if (x < p->element) find(x,p->left); else if (x>p->element) find(x,p->right); else cout<<"Element found !"; } void bst::copy(bs_nodeptr &p,bs_nodeptr &p1) { makeempty(p1); p1 = bs_nodecopy(p); } void bst::makeempty(bs_nodeptr &p) { bs_nodeptr d; if (p != NULL) { makeempty(p->left); makeempty(p->right); d=p; free(d); p=NULL; } } bs_nodeptr bst::bs_nodecopy(bs_nodeptr &p) { bs_nodeptr temp; if (p==NULL) return p; else { temp = new bs_node; temp->element = p->element; temp->left = bs_nodecopy(p->left); temp->right = bs_nodecopy(p->right); return temp; } } void bst::del(int x,bs_nodeptr &p) { bs_nodeptr d; if (p==NULL) cout<<"Element not found"; else if ( x < p->element) del(x,p->left); else if (x > p->element) del(x,p->right); else if ((p->left == NULL) && (p->right == NULL)) { d=p; free(d); p=NULL; cout<<" Element deleted !"; } else if (p->left == NULL) { d=p; free(d); p=p->right; cout<<" Element deleted !"; } else if (p->right == NULL) { d=p; p=p->left; free(d); cout<<" Element deleted !"; } else p->element = deletemin(p->right); } int bst::deletemin(bs_nodeptr &p) { int c; cout<<"inside deltemin"; if (p->left == NULL) { c=p->element; p=p->right; return c; } else { c=deletemin(p->left); return c; } } void bst::preorder(bs_nodeptr p) { if (p!=NULL) { cout<<p->element<<"-->"; preorder(p->left); preorder(p->right); } } void bst::inorder(bs_nodeptr p) { if (p!=NULL) { inorder(p->left); cout<<p->element<<"-->"; inorder(p->right); } } void bst::postorder(bs_nodeptr p) { if (p!=NULL) { postorder(p->left); postorder(p->right); cout<<p->element<<"-->"; } } int bst::bsheight(bs_nodeptr p) { int t; if (p == NULL) return -1; else { t = p->height; return t; } } bs_nodeptr bst:: srl(bs_nodeptr &p1) { bs_nodeptr p2; p2 = p1->left; p1->left = p2->right; p2->right = p1; p1->height = maxx(bsheight(p1->left),bsheight(p1->right)) + 1; p2->height = maxx(bsheight(p2->left),p1->height) + 1; return p2; } bs_nodeptr bst:: srr(bs_nodeptr &p1) { bs_nodeptr p2; p2 = p1->right; p1->right = p2->left; p2->left = p1; p1->height = maxx(bsheight(p1->left),bsheight(p1->right)) + 1; p2->height = maxx(p1->height,bsheight(p2->right)) + 1; return p2; } bs_nodeptr bst:: drl(bs_nodeptr &p1) { p1->left=srr(p1->left); return srl(p1); } bs_nodeptr bst::drr(bs_nodeptr &p1) { p1->right = srl(p1->right); return srr(p1); } int bst::nobs_nodes(bs_nodeptr p) { int count=0; if (p!=NULL) { nobs_nodes(p->left); nobs_nodes(p->right); count++; } return count; } bst::bst() { clrscr(); bs_nodeptr root,root1,minn,maxx; int a,choice,findele,delele,leftele,rightele,flag; root =NULL; root1=NULL; while(1) { cout<<"\n\tOperations on Binary Search tree..\n"; cout<<"\t\t1. Insertion\n"; cout<<"\t\t2. FindMin\n"; cout<<"\t\t3. FindMax\n"; cout<<"\t\t4. Find\n"; cout<<"\t\t5. Copy\n"; cout<<"\t\t6. Delete\n"; cout<<"\t\t7. Preorder\n"; cout<<"\t\t8. Inorder\n"; cout<<"\t\t9. Postorder\n"; cout<<"\t\t10. Height\n"; cout<<"\t\t11. To main page\n"; cout<<"\t\t12. Exit\n"; cout<<"\n\t\t Enter Your Choice= "; cin>>choice; switch(choice) { case 1: cout<<"Enter new bs_nodes value:"; cin>>a; insert(a,root); break; case 2: if (root !=NULL) { minn=findmin(root); cout<<"Min element : "<<minn->element; } break; case 3: if (root !=NULL) { maxx=findmax(root); cout<<"Max element : "<<maxx->element; } break; case 4: cout<<"Enter Search bs_node :"; cin>>findele; if (root != NULL) find(findele,root); break; case 5: copy(root,root1); inorder(root1); break; case 6: cout<<"Enter bs_node that u want to delete:"; cin>>delele; del(delele,root); inorder(root); break; case 7: cout<<" Preorder travers... :"; preorder(root); break; case 8: cout<<" Inorder travers.... :"; inorder(root); break; case 9: cout<<" Postorder travers... :"; postorder(root); break; case 10: cout<<" Height and Depth is "; cout<<bsheight(root); cout<<"\nNo. of bs_nodes is "<<nobs_nodes(root); break; case 11: return; case 12: exit(1); default: cout<<"\n\t\tWrong Choice, Enter Again\n"; } } } /*=========================14Nov.,2010=============================*/ Posted by Mangi Lal Sharma at 11/29/2012 10:14:00 am 2 comments: Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: DSA Lab Priority Queue operations /*Program to empelement Priority Queue operations compiler- Turbo c++ author- Mangilal Sharma --------------------------------------------------------*/ #include<iostream.h> #include<conio.h> #include<process.h> matriculation pqueue { int front,rear,choice; public: struct data { int val,p,o; }d[MAX]; void insert(); void deletion(); void display(); pqueue(); }; void pqueue::insert() { data d1; if(rear==MAX-1) cout<<"Priority Queue is Full"; else { cout<<"Enter Value "; cin>>d1.val; cout<<"Enter Priority "; cin>>d1.p; cout<<"Enter Order "; cin>>d1.o; rear++; d[rear]=d1; if(front==-1) front=0; data temp; for(int i=front;i<=rear;i++) for(int j=i+1;j<=rear;j++) { if(d[i].p > d[j].p) { temp=d[i]; d[i]=d[j]; d[j]=temp; } else { if(d[i].p==d[j].p) if(d[i].o > d[j].o) { temp=d[i]; d[i]=d[j]; d[j]=temp; } } } } } void pqueue::deletion() { if(front==-1) cout<<"Priority Queue is Empty"; else { cout<<"deleted followings...\n"; cout<<"Value = "<<d[front].val<<endl; cout<<"Priority = "<<d[front].p<<endl; cout<<"Order = "<<d[front].o<<endl; if(front==rear) front=rear=-1; else front++; } } void pqueue::display() { if(front==-1) cout<<"Priority Queue is Empty"; else { for(int i=front;i<=rear;i++) { cout<<"Object :"<<i+1<<endl; cout<<"Value ="<<d[i].val<<endl; cout<<"Priority="<<d[i].p<<endl; cout<<"Order = "<<d[i].o<<endl<<endl; } } } pqueue::pqueue() { front=rear=-1; while(1) { int choice; cout<<"\n\t\t\t PRIORITY QUEUE\n"; cout<<"\t\t1. To Insert an Element in priority Queue\n"; cout<<"\t\t2. To Delete an Element from priority Queue\n"; cout<<"\t\t3. ToExhibitthe Elements of priority Queue\n"; cout<<"\t\t4. To Main menu\n"; cout<<"\t\t5. To Exit from Programme\n"; cout<<"\n\t\t Enter Your Choice= "; cin>>choice; switch(choice) { case 1: insert();break; case 2: deletion();break; case 3: display();break; case 4: return; case 5: exit(1); default: cout<<"\n\t\tWrong Choice, Enter Again\n"; } } } /*=========================8Nov.,2010=============================*/ Posted by Mangi Lal Sharma at 11/29/2012 10:12:00 am No comments: Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: DSA Lab Doubly Linked List operations /*Program to impelement Doubly Linked List operations compiler- Turbo c++ author- Mangilal Sharma --------------------------------------------------------*/ #include<iostream.h> #include<conio.h> #include<stdlib.h> matriculation doubly { struct d_node { int data; d_node *rnext; d_node *lnext; }*new1,*head,*tail,*ptr,*temp; public: void creation(); void insertion(); void deletion(); void display(); doubly(); }; void doubly :: creation() { if(head==NULL) { new1=new d_node[sizeof(d_node)]; new1->rnext=NULL; new1->lnext=NULL; cout<<"enter No. of nodes:"; cin>>new1->data; head=new1; tail=new1; head->rnext=tail; head->lnext=tail; tail->rnext=head; tail->lnext=head; } else cout<<"Creation washed-up only once !"; } void doubly :: insertion() { int i,pos; new1=new d_node[sizeof(d_node)]; new1->rnext=NULL; new1->lnext=NULL; cout<<"enter number:"; cin>>new1->data; cout<<"enter position you want to insert:"; cin>>pos; if(pos==1) { new1->rnext=head; head=new1; tail->lnext=head; tail->rnext=head; head->lnext=tail; } else { i=1; temp=head; while(i < pos-1 && temp->rnext!=tail) { i++; temp=temp->rnext; } if(temp->rnext==tail) { new1->rnext=tail->rnext; tail->rnext=new1; new1->lnext=tail; tail=new1; head->lnext=tail; } else { new1->rnext=temp->rnext; new1->lnext=temp; temp->rnext=new1; new1->rnext->lnext=new1; } } } void doubly::deletion() { int pos,i; cout<<"Enter Position you want to Delete ?"; cin>>pos; if(pos==1 && head!=tail) { ptr=head; head=head->rnext; head->lnext=tail; tail->rnext=head; delete ptr; } else { i=1; temp=head; while(i < pos-1 && temp->rnext!=tail) { i++; temp=temp->rnext; } if(temp->rnext!=tail) { ptr=temp->rnext; temp->rnext=ptr->rnext; ptr->rnext->lnext=ptr->lnext; delete ptr; } else { if(temp->rnext==tail && head!=tail) { ptr=tail; tail=temp; tail->rnext=head; head->lnext=tail; delete ptr; } else { head=NULL; tail=NULL; delete head; delete tail; } } } } void doubly::display() { int ch; cout<<"1.forward traverse\n2.backward traverse"; cout<<"Enter your choice<1/2>? :"; cin>>ch; switch(ch) { specimen 1: if(head!=NULL) { temp=head; while(temp!=tail) { cout<<temp->data<<" "; temp=temp->rnext; } if(temp==tail) cout<<temp->data; } break; specimen 2 : if(tail!=NULL) { temp=tail; while(temp!=head) { cout<<temp->data<<" "; temp=temp->lnext; } if(temp==head) cout<<temp->data; } break; } } doubly::doubly() { head=tail=NULL; int choice; while(1) { cout<<"\n\t\tOperations on Doubly linked List..\n"; cout<<"\t\t1. To Create a linked list\n"; cout<<"\t\t2. To Insert an Element from linked list\n"; cout<<"\t\t3. To Delete the Elements of linked list\n"; cout<<"\t\t4. ToExhibitthe elements\n"; cout<<"\t\t5. To Main menu\n"; cout<<"\t\t6. To Exit from Programme\n"; cout<<"\n\t\t Enter Your Choice= "; cin>>choice; switch(choice) { case 1 : creation();break; case 2 : insertion();break; case 3 : deletion();break; case 4 : display();break; case 5 : return; case 6 : exit(1); } } } /*=========================10Nov.,2010=============================*/ Posted by Mangi Lal Sharma at 11/29/2012 10:11:00 am No comments: Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: DSA Lab Deapth First Search (DFS) graph traversal /*Program to create a graph and use Deapth First Search(DFS) compiler- Turbo c++ author- Mangilal Sharma --------------------------------------------------------*/ #include<conio.h> #include<iostream.h> #include<stdlib.h> /*struct node // Structure for elements in the graph { int data,status; struct node *next; struct link *adj; }; struct link // Structure for proximity list { struct node *next; struct link *adj; };*/ matriculation dfs { public: void create(); // For creating a graph dfs(); struct node *start,*p,*q; struct link *l,*k; }; void dfs::create() // Creating a graph { int dat,flag=0; start=NULL; cout<<"Enter the nodes in the graph(0 to end): "; while(1) { cin>>dat; if(dat==0) break; p=new node; p->data=dat; p->status=0; p->next=NULL; p->adj=NULL; if(flag==0) { start=p; q=p; flag++; } else { q->next=p; q=p; } } p=start; while(p!=NULL) { cout<<"Enter the links to "<<p->data<<" (0 to end) : "; flag=0; while(1) { cin>>dat; if(dat==0) break; k=new link; k->adj=NULL; if(flag==0) { p->adj=k; l=k; flag++; } else { l->adj=k; l=k; } q=start; while(q!=NULL) { if(q->data==dat) k->next=q; q=q->next; } } p=p->next; } cout<<"-------------------------"; return; } // Deapth First Search(DFS) Traversal. void dfs::dfs() { char ch='y'; while(ch=='y'||ch=='Y') { clrscr(); create(); int stack[25],top=1; cout<<"Deapth First Search Results"; cout<<"---------------------------"; p=start; while(p!=NULL) { p->status=0; p=p->next; } p=start; stack[0]=0; stack[top]=p->data; p->status=1; while(1) { if(stack[top]==0) break; p=start; while(p!=NULL) { if(p->data==stack[top]) break; p=p->next; } cout<<stack[top]<<" "; top--; k=p->adj; while(k!=NULL) { q=k->next; if(q->status==0) { top++; stack[top]=q->data; q->status=1; } k=k->adj; } } cout<<"\n\nEnter Y/y For then enter:"; cin>>ch; }return; } /*=========================17Nov.,2010=============================*/ Posted by Mangi Lal Sharma at 11/29/2012 10:09:00 am No comments: Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: DSA Lab Dequeue (Double-ended queue) operations /*Program to impelement Dequeue operations compiler- Turbo c++ author- Mangilal Sharma --------------------------------------------------------*/ #include<iostream.h> #include<conio.h> #include<process.h> #define max 5 matriculation dqueue { private: int queue_arr[max],rear,front,choice; public: void insertL(); void insertR(); void delL(); void delR(); void display(); void menu(int); dqueue(); }; void dqueue::insertL() { int added_item; if(front==0) { cout<<"Queue is Overflow\n"; return; } else { cout<<"\n Insert the element for subtracting in DeQueue: "; cin>>added_item; } front=front-1; queue_arr[front]=added_item; } void dqueue::insertR() { int added_item; if(rear==(max-1)) { cout<<"Queue is Overflow\n"; return; } else { cout<<"\n Insert the element for subtracting in DeQueue: "; cin>>added_item; } if(front==-1) front=0; rear=rear+1; queue_arr[rear]=added_item; } void dqueue::delR() { if(front==rear+1) { cout<<"DeQueue is Underflow\n"; return; } else cout<<"Element delete from DeQueue is "<<queue_arr[rear]; rear=rear-1; } void dqueue::delL() { if(front==rear+1) { cout<<"DeQueue is Underflow\n"; return; } else cout<<"Element delete from DeQueue is "<<queue_arr[front]; front=front+1; } void dqueue::display() { int i; if(front<=rear) { cout<<"DeQueue is:\n"; for(i=front;i<=rear;i++) cout<<queue_arr[i]; cout<<"\n"; } else { cout<<"Dequeue is empty"; } } void dqueue::menu(int n) { while(1) { cout<<"\n\t\t\t Menu"; cout<<"\n\n\t\t1. To Insert an Element\n"; if(n==2) cout<<"\t\t2. To Insert an Element at left\n"; if(n==1) cout<<"\t\t2. To Delete an Element from right\n"; cout<<"\t\t3. To Delete an Element\n"; cout<<"\t\t4. ToExhibitthe Elements of DeQueue\n"; cout<<"\t\t5. To Exit from Programme\n"; cout<<"\n\t\t Enter Your Choice= "; cin>>choice; switch(choice) { case 1:insertR();break; case 2:if(n==1)delR(); if(n==2)insertL();break; case 3:delL();break; case 4:display();break; case 5:exit(1); default: cout<<"\n\t\tWrong Choice, Enter Again\n"; } } } dqueue::dqueue() { rear=-1,front=-1; cout<<"\n\t\t\t DQUEUE\n"; cout<<"\t\t1. input restriced dequeue\n"; cout<<"\t\t2. output restriced dequeue\n"; cout<<"\t\t3. To main menu\n"; cout<<"\t\t4. To Exit from Programme\n"; cout<<"\n\t\t Enter Your Choice= "; cin>>choice; switch(choice) { specimen 1: menu(1);break; specimen 2: menu(2);break; specimen 3: return; specimen 4: exit(1); default: cout<<"\n\t\tWrong Choice, Enter Again\n"; } } /*=========================6Nov.,2010=============================*/ Posted by Mangi Lal Sharma at 11/29/2012 10:08:00 am No comments: Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: DSA Lab Older Posts Home Subscribe to: Posts (Atom) Labels DSA Lab (20) C vital lab (16) OS Lab (12) DAA Lab (7) Graphics Lab (5) C++ vital lab (4) Attention (3) Compiler Lab (3) FORUM (1) Problems (1) Welcome (1) Feedjit Feedjit Live Blog Stats About Me Mangi Lal Sharma View my well-constructed profile My other blogs mangilalsaraswat.blogspot.com Total Pageviews Get My Help To Write Your Program mangilalsharma Fiverr Seller Main Skills: WordPress, C, C++, Java, PHP. I have wits in WordPress 5 years, C 8 years, C++ 7 years, Java 5 years and PHP 5 years. My services contains everything related to websites and desktop software. Blog Archive ▼ 2015 (3) ▼ September (3) Factset Question: Subarray of k Size from a Array ... C program for User specified Custom atoi Function Co... C Program to Demonstrate use of atoi Function ► 2014 (3) ► November (3) ► 2013 (9) ► July (1) ► June (6) ► April (1) ► March (1) ► 2012 (50) ► December (3) ► November (47) Flagcounter Copyright by world-of-c-programming.blogspot.com. Simple theme. Powered by Blogger.