S:NO PROGRAM NAME PAGE NO 1. ARRAYS CREATION AND OPERATIONS 2(A) . STACK OPERATION 2(B) . QUEUE OPERATION 3. RECURSION,INFIX TO POSTFIX CONVERSION 4. POLYNOMIAL ADDITION USING SINGLY LINKED LIST 5. DOUBLY LINKED LIST OPERATIONS 6. TREE TRAVERSALS 7. GRAPH-SHORTEST PATH 8(A) . LINEAR SEARCHING 8(B) . BINARY SEARCHING 9. SORTING-SHELL,QUICK,HEAP,MERGE PRACTICAL I: PROBLEM SOLVING IN C & DATA STRUCTURES LAB
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
S:NO PROGRAM NAME PAGE NO1. ARRAYS CREATION AND OPERATIONS
2(A). STACK OPERATION
2(B). QUEUE OPERATION
3. RECURSION,INFIX TO POSTFIX CONVERSION
4. POLYNOMIAL ADDITION USING SINGLY LINKED LIST
5. DOUBLY LINKED LIST OPERATIONS
6. TREE TRAVERSALS
7. GRAPH-SHORTEST PATH
8(A). LINEAR SEARCHING
8(B). BINARY SEARCHING
9. SORTING-SHELL,QUICK,HEAP,MERGE
PRACTICAL I: PROBLEM SOLVING IN C & DATA STRUCTURES LAB
int x;clrscr();printf("\n\nMain Menu");printf("\n\n\t1.Insert");printf("\n\n\t2.Delete");printf("\n\n\t3.List");printf("\n\n\t4.Exit");printf("\n\nEnter Your Choice : ");scanf("%d",&x);return x;
}void insert(int x) {
a[++pos] = x;}void delete(int x) {
int i,start;for(i = 0;i <= pos;i++) {
if(a[i] == x) {start = i;while(start <= n) {
a[start] = a[start + 1];start++;
}pos--;return ;
}}printf("\n\nNumber Not Found.....");getch();
}void list() {
int i;printf("\n\nItems in Array : ");for(i = 0;i <= pos;i++) {
int x;clrscr();printf("\n\n\t\t\t\tSTACK OPERATION\n\nMain Menu");printf("\n\n\t1.Push");printf("\n\n\t2.Pop");printf("\n\n\t3.List");printf("\n\n\t4.Exit");printf("\n\nEnter Your Choice : ");scanf("%d",&x);return x;
}void push(int a) {
stk[++tos] = a;}int pop() {
int temp;temp = stk[tos];tos--;return temp;
}void list() {
int i;clrscr();printf("\n\nStack Elements : ");for(i = tos;i >= 0;i--) {
int x;clrscr();printf("\n\n\t\t\t\tQUEUE OPERATION\n\nMain Menu");printf("\n\n\t1.Insert");printf("\n\n\t2.Delete");printf("\n\n\t3.List");printf("\n\n\t4.Exit");printf("\n\nEnter Your Choice : ");scanf("%d",&x);return x;
clrscr();printf("\n\nElements in the List : ");trace = dlist;while(trace!=NULL) {
printf("%d ",trace->data);trace = trace->next;
}getch();
}int menu() {
int x;clrscr();printf("\n\n\t\t\t\tDOUBLY LINKED LIST\n\nMain Menu");printf("\n\n\t1.Insert");printf("\n\n\t2.Delete");printf("\n\n\t3.List");printf("\n\n\t4.Exit");printf("\n\nEnter Your Choice : ");scanf("%d",&x);return x;
}void main() {
int ch,x;clrscr();while((ch = menu()) < 5) {
switch(ch) {case 1:
printf("\n\nEnter a Number to Insert : ");scanf("%d",&x);insert(x);break;
case 2:if(dlist!=NULL) {
printf("\n\nEnter the Number to Delete : ");scanf("%d",&x);delete(x);
}else
printf("\n\nList Empty......");getch();break;
case 3:if(dlist!=NULL)
list();else
printf("\n\nList Empty......");
getch();break;
case 4:default:
exit(0);}
}getch();
}
OUTPUT
DOUBLY LINKED LIST
Main Menu
1.Insert
2.Delete
3.List
4.Exit
Enter Your Choice : 1
Enter a Number to Insert : 25
DOUBLY LINKED LIST
Main Menu
1.Insert
2.Delete
3.List
4.Exit
Enter Your Choice : 1
Enter a Number to Insert : 84
DOUBLY LINKED LIST
Main Menu
1.Insert
2.Delete
3.List
4.Exit
Enter Your Choice : 1
Enter a Number to Insert : 77
DOUBLY LINKED LIST
Main Menu
1.Insert
2.Delete
3.List
4.Exit
Enter Your Choice : 3
Elements in the List : 77 84 25
DOUBLY LINKED LIST
Main Menu
1.Insert
2.Delete
3.List
4.Exit
Enter Your Choice : 2
Enter the Number to Delete : 25
Element Deleted.......
6.TREE TRAVERSALS
#include<stdio.h>#include<conio.h>typedef struct bin {
******************************* Tree Traversal*******************************
1.Insert
2.Inorder
3.Preorder
4.Postorder
5.Exit
Enter your Choice : 1
Enter the Element : 47
Add More Elements ?(y/n) : y
Enter the Element : 23
Where to Insert 47 left or right : l
Add More Elements ?(y/n) : y
Enter the Element : 78
Where to Insert 78 left or right : r
Add More Elements ?(y/n) : n
******************************* Tree Traversal*******************************
1.Insert
2.Inorder
3.Preorder
4.Postorder
5.Exit
Enter your Choice : 2
23
47
78
******************************* Tree Traversal*******************************
1.Insert
2.Inorder
3.Preorder
4.Postorder
5.Exit
Enter your Choice : 4
23
78
47
7.GRAPH-SHORTEST PATH
#include<stdio.h>#include<conio.h>#define MAX 1000int dist[10][10],n;void showAdjacency();void calcPath();void showShortPath();void main() {
int x,i,j;clrscr();printf("\n\nEnter No.of Nodes in the Graph : ");scanf("%d",&n);printf("\n\nEnter Weights for the Following Path...........\n\n");for(i = 1;i <= n;i++) {
int i;void quickSort(int, int);clrscr();printf("\n\nEnter Number of Elements : ");scanf("%d",&n);printf("\n\nEnter %d Numbers : ",n);for(i = 1;i <= n;i++)
int i;void mergeSort(int, int);clrscr();printf("\n\nEnter Number of Elements : ");scanf("%d",&n);printf("\n\nEnter %d Numbers : ",n);for(i = 0;i < n;i++)