QUEUE IN DATA STRUCTURE USING C

MeghajKumarMallick 351 views 20 slides Apr 08, 2020
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

This is an PPT of Data Structure using C .It include the following topic such as"QUEUE IN DATA STRUCTURE USING C ".


Slide Content

Presentation on:
QUEUE
Presented By:
MAYANK SETH
MCA/25002/18

QUEUE

Queue
Ordered collection of homogeneouselements
Non-primitive linear datastructure.
Anewelement is added at one end called
rear end and the existing elements are deleted
from the other end called frontend.
This mechanism is called First-In-First-Out
(FIFO).

Fig: Models of aQueue

Operations On AQueue
To insertion/addition
of element(ENQUEUE)
TO deletion/removal
of element(DEQUEUE)

ENQUEUE
Placing an item in a queue is called
“insertion or enqueue”, which is done
at the end of the queue called“rear”.

ALGORITHM OF INSERTION
Procedure Insert_Q(Q, n, item, rear)
if(rear=n) then Queue Full
rear=rear+1;
Q[rear]=Item;
end Insert_Q

DEQUEUE
Deleting an item in a queue is called
“deletion or dequeue”, which is done at the
beginning of the queue called“front”.

ALGORITHM Of DELETION
Procedure Delete_Q(Q, Front, Rear, Item)
if(front=rear)then Queue Empty
front=front+1;
Item=Q[front];
end Delete_Q

LINKED QUEUE
•A linked queue is a linear list commonly
implemented as singly link list but two
pointer i.e. Front and Rear.
•The start pointer of singly link list plays the
role of Front while pointer to last node play
role of Rear.

ALGORITHM OF INSERTION
Procedure Insert_link_Queue
call getnode(x);
DATA(x)=item;
Link(x)=Nil;
If(front=0)then front=rear=x;
Else
{
Link(rear)=x;
Rear =x;
}
End Insert_link_queue

ALGORITHM OF DELETEION
•Procedure delete_link_queue(front, item)
if(front=0)then call link-queue-empty()
Else
{
temp=front;
Item=data(temp);
Front=link(temp)
}
call Return(temp);
End delete_link_queue

CIRCULAR QUEUE
•In circular queue, the last position is
connected back to the first position to
make a circle
•The front and rear variable which
displayed a linear movement over a queue
displays a circular movement over the
queue.

ALGORITHM OF INSERTION
Procedure InsertCirQ(cirQ,front,rear,n,item)
rear=(rear+1) mod n
If(front=rear)then cirq-full
CirQ[rear]=item;
End InsertCirQ

ALGORITHM OF DELETION
Procedure delete-CirQ(cirQ, front, rear, n,
item)
if(front=rear)then cirQ-empty
front=(front+1) mod n
Item=cirQ(front);
End delete-CirQ

DEQUEU
Dequeu i.e double ended queue is a linear list in which
all insertion and deletion are made at both end.
The end are knows as left end or right end.
Input
restricted
Output
restricted
DEQUEU

QueueApplications
A queue of people at ticket-window: The person who
comes first gets the ticket first. The person who is
coming last is getting the tickets in last. Therefore, it
follows first-in-first-out (FIFO) strategy of queue.
The Phone answering system: The person who calls first
gets a response first from the phone answering system.
The person who calls last gets the response last.
Therefore, it follows first-in-first-out (FIFO) strategy of
queue.

Applications related to Computer
Science
Round Robin Scheduling.
It is a CPU scheduling algorithm where
each process is assigned a fixed time slot
in a cyclic way.
The processes (runtime) are to be inserted
into the queue first and then decremented
(by CPU execution time) for each iteration
through the queue until their runtime is
over.

•The queue can process only n number of
processes at a time, where n is it's
capacity.
•Only the first n processes need to be
processed, the others are to be ignored.
Tags