0% found this document useful (0 votes)
2 views1 page

Data Structures Lab Record

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Data Structures Lab Record

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Experiment 1: Array Implementation of Stack

Aim: To implement stack operations (Push, Pop, Display) using an array.

Program:
#include <stdio.h>
#define MAX 5
int stack[MAX];
int top = -1;
void push(int item){if(top==MAX-1)printf("Stack Overflow\n");else{top++;stack[top]=item;printf("%d pu
void pop(){if(top==-1)printf("Stack Underflow\n");else printf("%d popped\n",stack[top--]);}
void display(){if(top==-1)printf("Empty\n");else for(int i=top;i>=0;i--)printf("%d\n",stack[i]);}
int main(){int ch,item;while(1){printf("\[Link]\[Link]\[Link]\[Link]\nEnter choice: ");scanf("%
switch(ch){case 1:printf("Enter item: ");scanf("%d",&item);push(item);break;case 2:pop();break;case 3

Sample Output:
[Link]
[Link]
[Link]
[Link]
Enter choice: 1
Enter item: 10
10 pushed
Enter choice: 3
10

Experiment 2: Array Implementation of Queue


Aim: To implement Queue operations (Enqueue, Dequeue, Display) using an array.

Program:
#include <stdio.h>
#define MAX 5
int queue[MAX];
int front=-1,rear=-1;
void enqueue(int item){if(rear==MAX-1)printf("Overflow\n");else{if(front==-1)front=0;queue[++rear]=it
void dequeue(){if(front==-1||front>rear)printf("Underflow\n");else printf("%d dequeued\n",queue[front
void display(){if(front==-1||front>rear)printf("Empty\n");else for(int i=front;i<=rear;i++)printf("%d
int main(){int ch,item;while(1){printf("\[Link]\[Link]\[Link]\[Link]\nEnter choice: ");s
switch(ch){case 1:printf("Enter item: ");scanf("%d",&item);enqueue(item);break;case 2:dequeue();break

Sample Output:
[Link]
[Link]
[Link]
[Link]
Enter choice: 1
Enter item: 10
10 enqueued

Remaining experiments (3–14) follow the same pattern with C programs for:
Singly Linked List, Linked List Queue, Polynomial Operations, Infix to Postfix, BST, AVL Tree,
Heap, Dijkstra, Prim, Linear & Binary Search.

You might also like