Beruflich Dokumente
Kultur Dokumente
LAB MANUAL
Submitted by: -
INDEX
S.NO
1.
OBJECTIVE Write a Program to enter 10 numbers in an Array and print their sum. Write a Program for PUSH and POP Operations in Stack Write a Program for INSERT, DELETE and TRAVERSE Operations in Queue. Write a Program for Linear Search in an Array Write a Program for Binary Search in an Array. Write a Program for Different Operations in Linked List. a).Insert b).Delete c).Traverse d).Insert at TOP e).Insert at BOTTOM f).Insert at any Position g).Delete from TOP h). Delete from BOTTOM i). Delete from any Position j).Deletion of any Particular Item. Write a Program for Bubble Sorting in an Array . Write a Program for Insertion Sorting in an Array. Write a Program for Merge Sorting in an Array. Write a Program for Quick Sorting in an Array. Write a Program for different operations in Circular Linked List Write a Program for Addition and Deletion Operation in a Circular Queue.
Date of Practical
Date of Submission
Remark
Signature
2. 3.
4. 5. 6.
7. 8. 9. 10. 11.
12.
OBJECTIVE Write a Program for Different Operations in Doubly Linked List. a).Insert b).Delete c).Traverse d).Insert at TOP e).Insert at BOTTOM f).Delete from TOP g). Delete from BOTTOM Write a Program that implements the Priority Queue using an Array. Write a Program that implements the De Queue using an Array. Write a Program that implements a Binary Tree using an Array.
Date of Practical
Date of Submission
Remark
Signature
14.
15.
16.
#include<stdio.h> #include<conio.h> #define MAXSIZE 5 void push(); void pop(); void traverse(); int stack[MAXSIZE]; int Top=-1; void main() { int c; clrscr(); do { printf("\n\n ----------------Stack through Static Allocation-------------"); printf("\n1. Push "); printf("\n2. Pop "); printf("\n3. Traverse "); printf("\n4. Exit"); printf("\nEnter your choice"); scanf("%d",&c); switch(c) { case 1: push(); break; case 2: pop(); break; case 3: traverse(); break; case 4: exit(); break; default: printf("\nYou Entered Wrong Choice");
INPUT For PUSH Operation ----------------Stack through Static Allocation------------1. Push 2.Pop 3.Traverse 4. Exit Enter your choice 1 OUTPUT Enter the element to be inserted 3 Element Inserted INPUT For Traverse Operation ----------------Stack through Static Allocation------------1. Push 2.Pop 3.Traverse 4. Exit Enter your choice 3 OUTPUT 3 Element Traversed INPUT For POP Operation ----------------Stack through Static Allocation------------1. Push 2.Pop 3.Traverse 4. Exit Enter your choice 2 OUTPUT Deleted Element 3 INPUT
Signature of Faculty
#include<stdio.h> #include<conio.h> #define MAXSIZE 5 void qinsert(); void qdelete(); void qtraverse(); int f=-1,r=-1,c,q[5]; void main() { clrscr(); do { printf("\n\n--------------Queue through Static Allocation------------"); printf("\n 1 : Insert \n 2 : Delete \n 3 : Traverse \n 4 : Exit"); printf("\n Enter your choice : "); scanf("%d",&c); switch(c) { case 1 : qinsert(); break; case 2 : qdelete(); break; case 3 : qtraverse(); break; case 4 : return; default : printf("\n U've entered Wrong Choice."); } }while(1); } void qinsert()
INPUT
getch();
INPUT:- enter 10 numbers in an Array 1 2 3 4 5 6 7 8 9 10 Enter the number to be searched 5 OUTPUT: 5 is present at location 5 5 is present 1 time in array
Signature of Faculty
6. Write a Program for Different Operations in Linked List. a) Insert b) Delete c)Traverse d)Insert at TOP e)Insert at BOTTOM f)Insert at any Position g) Delete from TOP h) Delete from BOTTOM i) Delete from any Position j) Deletion of any Particular Item.
DATE:#include<stdio.h> #include<conio.h> #include<malloc.h> struct node { int n; struct node *next; }*start=NULL,*temp,*ptr; typedef struct node l; void ins(); void del(); void traverse(); void instop(); void insbot(); void inspos(); void deltop();
INPUT For Insertion at TOP ..Linked List. 1. Insertion at Top 2. Insertion at Bottom 3. Insertion at any Position 4. Deletion at Top 5. Deletion at Bottom 6. Deletion from a Particular Position 7. Deletion of a Particular Element 8. Traverse 9. Exit Enter your choice 1 Enter element you want to insert 5 OUTPUT Element Inserted at Top.
INPUT For Insertion at BOTTOM ..Linked List. 1. Insertion at Top 2. Insertion at Bottom 3. Insertion at any Position 4. Deletion at Top 5. Deletion at Bottom 6. Deletion from a Particular Position 7. Deletion of a Particular Element
INPUT For Insertion at any Position ..Linked List. 1. Insertion at Top 2. Insertion at Bottom 3. Insertion at any Position 4. Deletion at Top 5. Deletion at Bottom 6. Deletion from a Particular Position 7. Deletion of a Particular Element 8. Traverse 9. Exit Enter your choice 3 Enter element you want to insert 9 Enter the Position where you want to insert the Element 2 OUTPUT Element Inserted at 2nd Position INPUT For Deletion at TOP ..Linked List. 1. Insertion at Top 2. Insertion at Bottom 3. Insertion at any Position 4. Deletion at Top 5. Deletion at Bottom 6. Deletion from a Particular Position
INPUT For Deletion at Bottom ..Linked List. 1. Insertion at Top 2. Insertion at Bottom 3. Insertion at any Position 4. Deletion at Top 5. Deletion at Bottom 6. Deletion from a Particular Position 7. Deletion of a Particular Element 8. Traverse 9. Exit Enter your choice 5
INPUT For Deletion from a Particular Position ..Linked List. 1. Insertion at Top 2. Insertion at Bottom 3. Insertion at any Position 4. Deletion at Top 5. Deletion at Bottom 6. Deletion from a Particular Position 7. Deletion of a Particular Element
INPUT For Deletion of a Particular Element ..Linked List. 1. Insertion at Top 2. Insertion at Bottom 3. Insertion at any Position 4. Deletion at Top 5. Deletion at Bottom 6. Deletion from a Particular Position 7. Deletion of a Particular Element 8. Traverse 9. Exit Enter your choice 7 Enter element which you want to delete 9 OUTPUT Element Deleted INPUT For Traversing ..Linked List. 1. Insertion at Top 2. Insertion at Bottom 3. Insertion at any Position 4. Deletion at Top 5. Deletion at Bottom
INPUT For Exit ..Linked List. 1. Insertion at Top 2. Insertion at Bottom 3. Insertion at any Position 4. Deletion at Top 5. Deletion at Bottom 6. Deletion from a Particular Position 7. Deletion of a Particular Element 8. Traverse 9. Exit Enter your choice 9 OUTPUT Exit from Program.
Signature of Faculty
DATE:-
13. Write a Program for Different Operations in Doubly Linked List. a).Insert b).Delete c).Traverse d).Insert at TOP e).Insert at BOTTOM f).Delete from TOP g). Delete from BOTTOM
#include<stdio.h> #include<conio.h> #include<malloc.h> struct node { int n; struct node *l,*r; }*start=NULL,*temp; void ins(); void del(); void traverse(); void instop(); void insbot(); void deltop(); void delbot(); void main() { int c; clrscr(); do { printf("\n ---------------------Doubly Linked List--------------------------\n"); printf("\n 1 : Insertion at Top "); printf("\n 2 : Insertion at Bottom "); printf("\n 3 : Deletion at Top "); printf("\n 4 : Deletion at Bottom "); printf("\n 5 : Traverse "); printf("\n 6 : Exit "); DATE:-
14. Write a Program that implements the Priority Queue using an Array.
#include<stdio.h> #include<conio.h> #define MAX 5 struct data { char job[MAX]; int prno; int ord; }; struct pque { struct data d[MAX]; int front; int rear; }; void initpque(struct pque *); void add(struct pque *,struct data); struct data delete(stuct pque *); void main() { struct pque q; struct data dt,temp; int i,j=0; clrscr(); initpque(&q); printf(Enter Job Description(max 4 chars) and its priority\n); printf(lower the priority number,higher the priority\n); printf(job priority\n); for(i=0;i<MAX;i++) DATE:-
printf("ENTER THE ELEMENT TO BE INSERTED :"); scanf("%d",&q[rear]); printf("\ QUEUE AFTER INSERTION :"); print(); } } void delbeg() { if(front==-1) printf("QUEUE EMPTY"); else { printf("ELEMENT DELETED : %d",q[front]); if(front==rear) { front=-1; rear=-1; } else if(front==max-1) front=0; else front++; printf("\ QUEUE AFTER DELETION :"); print(); } } void insertbeg() { if((front==rear+1)||((front==0)&&(rear==max-1))) printf("QUEUE IS FULL"); else {
printf("ENTER THE ELEMENT TO BE INSERTED :"); scanf("%d",&q[front]); printf("\ QUEUE AFTER INSERTION :"); print(); } } void delrear() { if(front==-1) printf("QUEUE EMPTY"); else { printf("ELEMENT DELETED : %d",q[rear]); if(front==rear) { front=-1; rear=-1; } else if(rear==0) rear=max-1; else rear--; printf("\ QUEUE AFTER DELETION :"); print(); } } void main() { int ch;