SlideShare a Scribd company logo
2
Most read
3
Most read
11
Most read
BY :
SADIA ZAR
Two Basic Operations in Queue
Enque : Inserting new element from rear end
Deque : Removing existing element from
front end
Front End
Rear End
0 1 2 3 4 5 6
#include <iostream>
using namespace std;
class Queue
{
int* array,size,f,r,count;
public:
Queue();
void Enque(int value);
int Deque();
bool is_Empty();
bool is_Full();
};
Queue::Queue()
{
cout<<"Enter size : ";
cin>>size;
array=new int[size];
f=r=-1;
count=0;
}
void Queue::Enque(int value)
{
if(!is_Full())
{
array[++r]=value;
count++;
}
else
{
cout<<"nnOverFlow ! nn";
}
}
int Queue::Deque()
{
if(!is_Empty())
{
count--;
return array[++f];
}
else
{
cout<<"nnUnderFlow ! nn";
}
}
bool Queue::is_Empty()
{
return f==r==-1;
}
bool Queue::is_Full()
{
return count==size;
}
void main()
{
Queue obj;
obj.Enque(1);
obj.Enque(2);
obj.Enque(3);
obj.Deque();
}
1 2 3
0 1 2 3 4 5 6
Queue Implementation Using Array & Linked List
#include <iostream>
using namespace std;
class Node
{
int value;
Node*next;
friend class Queue;
public:
Node()
{
next=NULL;
}
};
class Queue
{
Node *first,*last;
public:
Queue()
{
first=last=NULL;
}
void Enque(int v);
bool is_Empty();
void Deque();
void Display();
};
first
last
void Queue::Enque(int v)
{
Node *n=new Node();
n->value=v;
if(first==NULL)
{
last=first=n;
}
else
{
last->next=n;
last=n;
}
}
DATA
NEXT
void Queue::Deque()
{
if(!is_Empty())
{
Node *temp=first;
first=first->next;
cout<<"nnThe data Dequeued is :
"<<temp->value<<endl;
delete temp;
}
}
bool Queue::is_Empty()
{
return first==NULL||last==NULL;
}
void Queue::Display()
{
Node *p = new Node;
p = first;
cout<<"nnQueue Elements are : nn";
while(p!=NULL)
{
cout<<p->value<<endl;
p = p->next;
}
}
Void main()
{
Queue Q;
Q.Enque(12);
Q.Enque(15);
Q. Deque();
Q .Display();
}
100
200
12
15
200
NULL
100
200
first
last
200

More Related Content

What's hot (20)

PPTX
single linked list
Sathasivam Rangasamy
 
PPT
Linked List
CHANDAN KUMAR
 
PPTX
Topological Sorting
ShahDhruv21
 
PPTX
Trees
Burhan Ahmed
 
PPTX
Constructor in java
Pavith Gunasekara
 
PPTX
Data structure - Graph
Madhu Bala
 
PPTX
Abstract Data Types
karthikeyanC40
 
PPTX
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
PDF
Applications of stack
eShikshak
 
PDF
Stack
Zaid Shabbir
 
PPT
Hash table
Rajendran
 
PPTX
Queues
Ashim Lamichhane
 
PDF
Array data structure
maamir farooq
 
PPTX
trees in data structure
shameen khan
 
PDF
Queue
Budditha Hettige
 
PDF
sparse matrix in data structure
MAHALAKSHMI P
 
PPTX
Linked list
KalaivaniKS1
 
PPTX
Priority queue in DSA
junnubabu
 
PDF
Quick Sort , Merge Sort , Heap Sort
Mohammed Hussein
 
PPTX
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
single linked list
Sathasivam Rangasamy
 
Linked List
CHANDAN KUMAR
 
Topological Sorting
ShahDhruv21
 
Trees
Burhan Ahmed
 
Constructor in java
Pavith Gunasekara
 
Data structure - Graph
Madhu Bala
 
Abstract Data Types
karthikeyanC40
 
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
Applications of stack
eShikshak
 
Stack
Zaid Shabbir
 
Hash table
Rajendran
 
Array data structure
maamir farooq
 
trees in data structure
shameen khan
 
sparse matrix in data structure
MAHALAKSHMI P
 
Linked list
KalaivaniKS1
 
Priority queue in DSA
junnubabu
 
Quick Sort , Merge Sort , Heap Sort
Mohammed Hussein
 
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 

Viewers also liked (20)

PPTX
Ppt on Linked list,stack,queue
Srajan Shukla
 
PDF
Stacks,queues,linked-list
pinakspatel
 
PPTX
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Muhammad Hammad Waseem
 
PPT
Queue data structure
anooppjoseph
 
PPTX
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
PPT
Formulacion de-qumica-inorganica-120319205240-phpapp01-131119105305-phpapp02-...
Ariel Carrion
 
PPT
stack presentation
Shivalik college of engineering
 
PPT
Stacks and queue
Amit Vats
 
PPTX
Linked stacks and queues
Ramzi Alqrainy
 
PPT
Stacks, Queues, Deques
A-Tech and Software Development
 
PDF
Linked List Implementation of Deque in C
Kasun Ranga Wijeweera
 
DOC
Ds lab manual by s.k.rath
SANTOSH RATH
 
DOCX
Data structure new lab manual
SANTOSH RATH
 
PPTX
Stack and queue
Shakila Mahjabin
 
PPT
Stacks & Queues By Ms. Niti Arora
kulachihansraj
 
PPTX
Estructura de datos: lista, pilas y colas
Huascar Génere
 
PPTX
deque and it applications
Sathasivam Rangasamy
 
PPSX
Stacks Implementation and Examples
greatqadirgee4u
 
PDF
Queue as data_structure
eShikshak
 
Ppt on Linked list,stack,queue
Srajan Shukla
 
Stacks,queues,linked-list
pinakspatel
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Muhammad Hammad Waseem
 
Queue data structure
anooppjoseph
 
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
Formulacion de-qumica-inorganica-120319205240-phpapp01-131119105305-phpapp02-...
Ariel Carrion
 
stack presentation
Shivalik college of engineering
 
Stacks and queue
Amit Vats
 
Linked stacks and queues
Ramzi Alqrainy
 
Stacks, Queues, Deques
A-Tech and Software Development
 
Linked List Implementation of Deque in C
Kasun Ranga Wijeweera
 
Ds lab manual by s.k.rath
SANTOSH RATH
 
Data structure new lab manual
SANTOSH RATH
 
Stack and queue
Shakila Mahjabin
 
Stacks & Queues By Ms. Niti Arora
kulachihansraj
 
Estructura de datos: lista, pilas y colas
Huascar Génere
 
deque and it applications
Sathasivam Rangasamy
 
Stacks Implementation and Examples
greatqadirgee4u
 
Queue as data_structure
eShikshak
 
Ad

Similar to Queue Implementation Using Array & Linked List (20)

PPTX
Data Structures - Lecture 6 [queues]
Muhammad Hammad Waseem
 
PPTX
Queue
Ayaz Akhtar
 
PPTX
Queues_0748555555555555555555555526.pptx
nailapp2023
 
PPTX
Basic Queue Operation in DataStructure.pptx
LakshmiSamivel
 
PPTX
Queue and its operations
V.V.Vanniaperumal College for Women
 
PPT
Lecture 2d queues
Victor Palmar
 
PDF
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
playstore9ha
 
PPT
Queues in C++ detailed explanation and examples .ppt
Jamiluddin39
 
PDF
Polynomialmotilalanehrunationalinstitute.pdf
yugpadhiyar2006
 
PDF
chapter10-queue-161018120329.pdf
ssuserff72e4
 
PPSX
Data Structure (Queue)
Adam Mukharil Bachtiar
 
PPTX
Queue
Abdur Rehman
 
PPTX
The presention is about the queue data structure
gaurav77712
 
PPT
Algo>Queues
Ain-ul-Moiz Khawaja
 
PPTX
Queue Data Structure
Afaq Mansoor Khan
 
PPTX
queue.pptx
Dr.Shweta
 
PPTX
Queues
nidhisatija1
 
PDF
Data Structures and Algorithms-DSA_Linkedlist_class 7.pdf
Chethan Raddi
 
PPT
Queue data structure
Mekk Mhmd
 
PPTX
queue.pptx
NSudhaEccs
 
Data Structures - Lecture 6 [queues]
Muhammad Hammad Waseem
 
Queue
Ayaz Akhtar
 
Queues_0748555555555555555555555526.pptx
nailapp2023
 
Basic Queue Operation in DataStructure.pptx
LakshmiSamivel
 
Queue and its operations
V.V.Vanniaperumal College for Women
 
Lecture 2d queues
Victor Palmar
 
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
playstore9ha
 
Queues in C++ detailed explanation and examples .ppt
Jamiluddin39
 
Polynomialmotilalanehrunationalinstitute.pdf
yugpadhiyar2006
 
chapter10-queue-161018120329.pdf
ssuserff72e4
 
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Queue
Abdur Rehman
 
The presention is about the queue data structure
gaurav77712
 
Algo>Queues
Ain-ul-Moiz Khawaja
 
Queue Data Structure
Afaq Mansoor Khan
 
queue.pptx
Dr.Shweta
 
Queues
nidhisatija1
 
Data Structures and Algorithms-DSA_Linkedlist_class 7.pdf
Chethan Raddi
 
Queue data structure
Mekk Mhmd
 
queue.pptx
NSudhaEccs
 
Ad

Recently uploaded (20)

PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PPTX
How to Manage Expiry Date in Odoo 18 Inventory
Celine George
 
PPTX
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
PPTX
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
PPTX
Exploring Linear and Angular Quantities and Ergonomic Design.pptx
AngeliqueTolentinoDe
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PPTX
Navigating English Key Stage 2 lerning needs.pptx
JaysonClosa3
 
PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PPTX
SD_GMRC5_Session 6AB_Dulog Pedagohikal at Pagtataya (1).pptx
NickeyArguelles
 
PPTX
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
DOCX
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
 
PDF
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
PPTX
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 
Introduction presentation of the patentbutler tool
MIPLM
 
How to Manage Expiry Date in Odoo 18 Inventory
Celine George
 
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
Exploring Linear and Angular Quantities and Ergonomic Design.pptx
AngeliqueTolentinoDe
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
Navigating English Key Stage 2 lerning needs.pptx
JaysonClosa3
 
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
SD_GMRC5_Session 6AB_Dulog Pedagohikal at Pagtataya (1).pptx
NickeyArguelles
 
Ward Management: Patient Care, Personnel, Equipment, and Environment.pptx
PRADEEP ABOTHU
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
 
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 

Queue Implementation Using Array & Linked List