Micro Project of Data Structure Using C++ - 3rd SEM - CO
Micro Project of Data Structure Using C++ - 3rd SEM - CO
Title of Project
PERFORMING VAIROUS OPERATIONS ON
CIRCULAR QUEUE.
: Group Details:
1
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION.
CERTIFICATE
This is to certify that Mr./Mrs._________________________________________
Seal of
Institution
2
WEEKLY ACTIVITY SHEET:
Institution Code: 1547 Semester: Third Semester
3
INDEX
2 Algorithms 6
3
Program for Performing Operations on Circular Queue 7-9
5 Conclusion 12
6 Reference 13
4
WHAT IS A DATA STRUCTURE ?
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.
5
ALGORITHMS
6
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');
7
getch();
}
void insert()
{
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 position of Front=%d and
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 position of Front=%d and
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]);
}
} //End of program
9
OUTPUT:-
10
11
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.
12
REFERENCE:-
www.google.com.in
www.geeksforgeeks.org
www.programiz.com
www.includehelp.com
www.studytonight.com
13