0% found this document useful (0 votes)
13 views8 pages

Queue

Understanding Queue in good way

Uploaded by

koljoy31
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)
13 views8 pages

Queue

Understanding Queue in good way

Uploaded by

koljoy31
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
You are on page 1/ 8

TECHNO MAIN SALTLAKE

QUEUE ADT

• NAME: SAPTARSHI SARKAR


• DEPARTMENT: ELECTRONICS AND COMMUNICATION ENGINEERING (ECE-B)
• SUBJECT NAME: DATA STRUCTURE & ALGORITHMS
• SUBJECT CODE: ES-CS 301
• ROLL NO: 13000323085
• REGISTRATION NUMBER: 231300110690(2023-24)
CONTENTS
 INTRODUCTION

 BASIC OPERATIONS IN QUEUE

 TYPES OF QUEUE

 APPLICATIONS
INTRODUCTION
 Queue is a linear data structure that follows a particular order in which the operations
are performed for storing data.
 The order is First In First Out (FIFO). One can imagine a queue as a line of people
waiting to receive something in sequential order which starts from the beginning of the
line.
 It is an ordered list in which insertions are done at one end which is known as the rear
and deletions are done from the other end known as the front.
 The difference between stacks and queues is in removing. In a stack we remove the
item the most recently added; in a queue, we remove the item the least recently added.
BASIC OPERATIONS IN QUEUE
1.#define MAX_SIZE 100
2.int queue[MAX_SIZE]; ❑ enqueue(): Inserts an element at the end of the
3.int front = -1; queue i.e. at the rear end.
4.int rear = -1;
5. void enqueue(int element) { ❑ dequeue(): This operation removes and returns an
6. if (rear == MAX_SIZE - 1) { element that is at the front end of the queue.
7. printf(“OVERFLOW");
8. } ❑ front(): This operation returns the element at the
9. if (front == -1 && rear==-1) { front end without removing it.
10. front++;
11. rear++; ❑ rear(): This operation returns the element at the
12. queue[rear] = element; rear end without removing it.
13.}
14. ❑ isEmpty(): This operation indicates whether the
15.int dequeue() { queue is empty or not.
16. if (front == -1 || front > rear) {
17. printf("Queue is empty"); ❑ isFull(): This operation indicates whether the
18. } queue is full or not.
19. int element = queue[front];
20. front++; ❑ size(): This operation returns the size of the queue
21. return element; i.e. the total number of elements it contain.
22.}
TYPES OF QUEUE
1) Simple Queue: Simple queue also known as a linear queue is the most basic version of a
queue. Here, insertion of an element or Enqueue takes place at the rear end and removal of
an element or Dequeue takes place at the front end. Here problem is that if we pop some
item from front and then rear reach to the capacity of the queue and although there are
empty spaces in front means the queue is not full but as per condition in isFull() function, it
will show the queue is full.
2) Circular Queue: In a circular queue, the element of the queue act as a circular ring. The
working of a circular queue is similar to the linear queue except for the fact that the last
element is connected to the first element. Its advantage is that the memory is utilized in a
better way. This is because if there is an empty space then an element can be easily added at
that position using modulo capacity(%n).
3) Priority Queue: This queue is a special type of queue. Its specialty is that it arranges the
elements in a queue based on some priority. The priority can be something where the
element with the highest value has the priority so it creates a queue with decreasing order of
values.
4) Dequeue: Dequeue is also known as Double Ended Queue. As the name suggests double
ended, it means that an element can be inserted or removed from both ends of the queue,
unlike the other queues in which it can be done only from one end. Because of this property,
it may not obey the First In First Out property.
APPLICATIONS
Queue is used when things don’t have to be processed immediately, but have to be processed
in First In First Out order like Breadth First Search. This property of Queue makes it also useful in
following kind of scenarios.
❖ When a resource is shared among multiple consumers. Examples include CPU scheduling, Disk
Scheduling.
❖ When data is transferred asynchronously (data not necessarily received at same rate as sent)
between two processes. Examples include IO Buffers, pipes, file IO, etc.
❖ Multi programming: Multi programming means when multiple programs are running in the main
memory. It is essential to organize these multiple programs and these multiple programs are
organized as queues.
❖ Network: In a network, a queue is used in devices such as a router or a switch. another application of a
queue is a mail queue which is a directory that stores data and controls files for mail messages.
❖ Job Scheduling: The computer has a task to execute a particular number of jobs that are scheduled to
be executed one after another. These jobs are assigned to the processor one by one which is organized
using a queue.
❖ Shared resources: Queues are used as waiting lists for a single shared resource.
REFERENCES
❑ GeeksforGeeks.org

❑ Tutorialspoint.com

❑ Javatpoint.com

❑ ResearchGate
THANK
YOU

You might also like