MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION.
CERTIFICATE
This is to certify that
Mr./Mrs._________________________________________
Roll No.___________of Third Semester of Diploma in Computer Engineering of
institution, P.K Technical Campus (Code:1662) has completed the Micro project
satisfactorily in Subject Data Structure using ‘C’(313301)for the Academic year
2024-2025 as prescribed in the curriculum.
Place: Enrollment No:
Date: Exam No. seat:
Subject teacher Head of the Department Principal
Seal of Institution
1
INDEX
SR.NO. CONTENT
Introduction of Data Structure, Queue and Circular
`1
Queue
2 Algorithms
Program for Performing Operations on Circular Queue
3
4 Output Of Program
5 Conclusion
2
WHAT IS A DATA STRUCTURE
A data structure is a specialized format of organizing and storing the data.
Types of data structure
1. Primitive data type-
a) Integer
b) Real data type
c) Character
d) String
e) Pointer
2. Non-Primitive data type-
a) Array
b) List
I. Linear
• Stack
• Queue
II. Non-Linear
• Tree
• Graph
c) Files
What is Queue ?
Queue is a linear data structure which follows First-In-First-Out(FIFO) principle where elements
are added at rear end and deleted from the first end.
What is a Circular Queue ?
A queue in which last node is connected back to the first node to form a cycle, is called as
circular queue.
Applications Of Circular Queue:-
Adding large integers
Memory management
Computer controlled traffic system
3
ALGORITHMS
Algorithm to Implement Circular Queue=
1. FRONT= 1;
2. REAR= 0;
3. COUNT= 0;
4. RETURN;
• Algorithm to Insert /enqueue() an element in Circular Queue=
1. If (((front == 0) and (rear == MAX-1)) or (rear == front-1)
2. Print “Overflow”
3. If(front == -1)
4. Front = rear = 0
5. Else
6. Rear = (rear+1)%MAX
7. Queue[rear] = element
• Algorithm to Delete/dequeue() an element in Circular Queue=
1. If (front == -1)
2. Print “Underflow”
3. Element = QUEUE[front]
4. If (front == rear)
5. Front = rear = -1
6. Else
7. Front = (front+1)%MAX
Algorithm to check queue is Empty or not=
1. If (COUNT = 0) then;
2. EMPTY= true;
3. Else
4. EMPTY= false;
5. Return;
Algorithm to check queue is Full or not=
1. If (COUNT = MAX) then;
2. FULL= true;
3. Else
4
PROGRAM
Program to perform various operations on Circular Queue
#include<stdio.h>
#include<conio.h>
#include<string.h> #define max 3 int a[max],item,front=-
1,rear=-1; //initializing circular queue void insert(); void
delete(); void display(); void main()
{ int
choice;
char
ch='y';
clrscr();
printf("\n**********OPERATIONS ON CIRCULAR
QUEUE**********\n"); do {
printf("\n1:Insert\n");
printf("\n2:Delete\n");
printf("\n3:Display\n");
printf("\n4:Exit\n");
printf("\nEnter your choice:-
\n"); scanf("\n%d",&choice);
switch(choice)
{
case 1:insert();
break; case
2:delete();
break; case
3:display();
break; case
4:exit();
default:printf("\nYou entered wrong choice");
} printf("\nDo you want to continue(Y|N):-
\n"); scanf("%s",&ch);
}
while(ch=='y'||ch=='Y');
5
getch();
}
voidinsert()
{
if(front==rear+1)
{ printf("\nQueue is full!!!\n");
return;
}
else { printf("\nEnter the
element:-\n");
scanf("%d",&item); if(front==-
1) front=rear=0; else
rear=(rear+1)%max;
a[rear]=item;
}
printf("\n After insertion
Rear=%d\n",front,rear);
}
void
delete()
{
if(front==1)
{
printf("\nQueue is
empty!!!\n"); return;
} else { item=a[front];
printf("\nThe deleted element is:-
%d\n",item); if(front==rear) front=rear=-1;
else
front=(front+1)%max;
}
printf("\n After Deletion
Rear=%d\n",front,rear);
8
}
void
display() {
int i;
if(front==-1) { printf("\nQueue is
empty!!!\n"); return; } else {
printf("\nElement in Queue
are:\n"); for(i=front;i<=rear;i++)
printf("%d\t",a[i]); } if(front>rear)
{ for(i=front;i<max;i++)
printf("%d\t",a[i]);
for(i=0;i<=rear;i++)
printf("%d\t",a[i]);
}
return 0;
}
End of program
7
8
9
CONCLUSION:-
The purpose behind making this micro-project is to being interact with
Circular Queue, which is a subtype of Queue(A Linear Data Structure). With
the proper guidance of professor and taking reference from textbooks and
some websites, we had learn how to implement the basic operations like
Insertion, Deletion, Is_Full, Is_Empty, Front & Rear of Queue on Circular
Queue with the help of ‘C’ programming language.
And we had successfully implemented the program of various operations
on circular queue.
10