SlideShare a Scribd company logo
- By Sonali Soni
Introduction to Queue.
Operations on Queue.
Representation of Queue in memory.
Application of Queue.
Queue is an ordered group of homogeneous
items of elements.
A queue has two ends - front end & rear
end.
Insertion can take place at rear end &
deletion can take place at front end.
Queue is also known as First In First
Out(FIFO) data structure.
Insertion & Deletion operations are known
as Enqueue & Dequeue respectively.
Front Rear
The following operations are performed on
queue:-
1. CreateQueue(q)- To create q as an empty queue.
2. Enqueue(q, i)- To insert an element i in the
queue.
3. Dequeue(q)- To access & remove an element of
the queue.
4. Peek(q)- To access the first element of the
queue without removing it.
5. IsFull(q)- to check whether the queue is full.
6. IsEmpty(q)- To check whether the queue is
empty.
Queue can be represented in memory using linear
array or linear linked list.
A queue represented using a linked list is called a
linked queue.
The overflow condition for array implementation is
front is equal to zero & rear is equal to (size of
array)-1.
The underflow condition for array implementation is
front is equal to -1.
typedef struct nodetype
{
int info;
struct nodetype *next;
}node;
typedef struct
{
node *front;
node *rear;
}queue;
We define two datatypes- node &
queue.
The datatype queue, a structure
whose first element front holds the
address of first element of queue &
second element rear holds the
address of last element of the
queue.
front rear
5 10 20 0
CREATING AN EMPTY QUEUE
void CreateQueue(queue *pq)
{
pq->front=pq->rear=NULL;
}
The front and rear end of the queue are
initialized to NULL.
typedef enum {true,false}boolean;
boolean IsEmpty(queue *pq)
{
if(pq->front==NULL)
return true;
else
return false;
}
void Enqueue(queue *pq, int item)
{
node *ptr;
ptr=(node *)malloc(sizeof(node));
ptr->info=item;
ptr->next=NULL;
if(pq->rear==NULL)
pq->front=pq->rear=ptr;
else
{
(pq->rear)->next=ptr;
pq->rear=ptr;
}
}
int Dequeue(queue *pq)
{
int temp;
node *ptr;
temp=(pq->front)->info;
ptr=pq->front;
if(pq->front==pq->rear)
pq->front=pq->rear=NULL;
else
pq->front=(pq->front)->next;
free(ptr);
return temp;
}
Queue is used to access files from a
disk system.
In a multiprogramming environment,
queue is used for CPU scheduling or
job scheduling of operating system.
In ticket reservation system, queue
can be used for issuing tickets to the
customers.
Queue

More Related Content

What's hot

Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applicationsJsaddam Hussain
 
Queues in C++
Queues in C++Queues in C++
Queues in C++
Vineeta Garg
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
Muhazzab Chouhadry
 
Queue
QueueQueue
Queue
Raj Sarode
 
Queue as data_structure
Queue as data_structureQueue as data_structure
Queue as data_structure
eShikshak
 
Queue
QueueQueue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queueSenthil Kumar
 
Circular queue
Circular queueCircular queue
Queues
QueuesQueues
Queues
Hareem Aslam
 
QUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING CQUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING C
Meghaj Mallick
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
anooppjoseph
 
Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)
Self-Employed
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Stacks and Queue - Data Structures
Stacks and Queue - Data StructuresStacks and Queue - Data Structures
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
Rajendran
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
Mekk Mhmd
 

What's hot (20)

Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Queues in C++
Queues in C++Queues in C++
Queues in C++
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
 
Queue
QueueQueue
Queue
 
Leniar datastructure
Leniar datastructureLeniar datastructure
Leniar datastructure
 
Queue
QueueQueue
Queue
 
Queue as data_structure
Queue as data_structureQueue as data_structure
Queue as data_structure
 
Queue
QueueQueue
Queue
 
Queue oop
Queue   oopQueue   oop
Queue oop
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
 
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queue
 
Circular queue
Circular queueCircular queue
Circular queue
 
Queues
QueuesQueues
Queues
 
QUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING CQUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING C
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Stacks and Queue - Data Structures
Stacks and Queue - Data StructuresStacks and Queue - Data Structures
Stacks and Queue - Data Structures
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 

Similar to Queue

Data Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptxData Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptx
RashidFaridChishti
 
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx
NuraMohamed9
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
skilljiolms
 
Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)
Roman Rodomansky
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
soniya555961
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queue
Pulkitmodi1998
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
Dabbal Singh Mahara
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
Apurbo Datta
 
Queue and its operations
Queue and its operationsQueue and its operations
Queue and its operations
V.V.Vanniaperumal College for Women
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
SherinRappai
 
Queue
QueueQueue
6 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart36 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart3
SSE_AndyLi
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Afaq Mansoor Khan
 
Queue(lecture8).pptx
Queue(lecture8).pptxQueue(lecture8).pptx
Queue(lecture8).pptx
singhprpg
 
Data Structure Lecture 4
Data Structure Lecture 4Data Structure Lecture 4
Data Structure Lecture 4
Teksify
 
QUEUE.pptx
QUEUE.pptxQUEUE.pptx
QUEUE.pptx
MattFlordeliza1
 
Data structures
Data structuresData structures
Data structures
naveeth babu
 
Queue
QueueQueue
DS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptxDS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptx
VeerannaKotagi1
 

Similar to Queue (20)

Data Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptxData Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptx
 
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)
 
Lecture 2d queues
Lecture 2d queuesLecture 2d queues
Lecture 2d queues
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queue
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
Queue and its operations
Queue and its operationsQueue and its operations
Queue and its operations
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Queue
QueueQueue
Queue
 
6 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart36 chapter3 list_stackqueuepart3
6 chapter3 list_stackqueuepart3
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Queue(lecture8).pptx
Queue(lecture8).pptxQueue(lecture8).pptx
Queue(lecture8).pptx
 
Data Structure Lecture 4
Data Structure Lecture 4Data Structure Lecture 4
Data Structure Lecture 4
 
QUEUE.pptx
QUEUE.pptxQUEUE.pptx
QUEUE.pptx
 
Data structures
Data structuresData structures
Data structures
 
Queue
QueueQueue
Queue
 
DS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptxDS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptx
 

Recently uploaded

Landownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptxLandownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptx
JezreelCabil2
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
AG2 Design
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 

Recently uploaded (20)

Landownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptxLandownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 

Queue

  • 1. - By Sonali Soni
  • 2. Introduction to Queue. Operations on Queue. Representation of Queue in memory. Application of Queue.
  • 3. Queue is an ordered group of homogeneous items of elements. A queue has two ends - front end & rear end. Insertion can take place at rear end & deletion can take place at front end.
  • 4. Queue is also known as First In First Out(FIFO) data structure. Insertion & Deletion operations are known as Enqueue & Dequeue respectively. Front Rear
  • 5. The following operations are performed on queue:- 1. CreateQueue(q)- To create q as an empty queue. 2. Enqueue(q, i)- To insert an element i in the queue. 3. Dequeue(q)- To access & remove an element of the queue. 4. Peek(q)- To access the first element of the queue without removing it. 5. IsFull(q)- to check whether the queue is full. 6. IsEmpty(q)- To check whether the queue is empty.
  • 6. Queue can be represented in memory using linear array or linear linked list. A queue represented using a linked list is called a linked queue. The overflow condition for array implementation is front is equal to zero & rear is equal to (size of array)-1. The underflow condition for array implementation is front is equal to -1.
  • 7. typedef struct nodetype { int info; struct nodetype *next; }node; typedef struct { node *front; node *rear; }queue;
  • 8. We define two datatypes- node & queue. The datatype queue, a structure whose first element front holds the address of first element of queue & second element rear holds the address of last element of the queue.
  • 10. CREATING AN EMPTY QUEUE void CreateQueue(queue *pq) { pq->front=pq->rear=NULL; } The front and rear end of the queue are initialized to NULL.
  • 11. typedef enum {true,false}boolean; boolean IsEmpty(queue *pq) { if(pq->front==NULL) return true; else return false; }
  • 12. void Enqueue(queue *pq, int item) { node *ptr; ptr=(node *)malloc(sizeof(node)); ptr->info=item; ptr->next=NULL; if(pq->rear==NULL) pq->front=pq->rear=ptr; else { (pq->rear)->next=ptr; pq->rear=ptr; } }
  • 13. int Dequeue(queue *pq) { int temp; node *ptr; temp=(pq->front)->info; ptr=pq->front; if(pq->front==pq->rear) pq->front=pq->rear=NULL; else pq->front=(pq->front)->next; free(ptr); return temp; }
  • 14. Queue is used to access files from a disk system. In a multiprogramming environment, queue is used for CPU scheduling or job scheduling of operating system. In ticket reservation system, queue can be used for issuing tickets to the customers.