SlideShare a Scribd company logo
2
Most read
11
Most read
16
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

PDF
Python list
Mohammed Sikander
 
PPTX
Array in c programming
Mazharul Islam
 
PPTX
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
PPTX
STACKS IN DATASTRUCTURE
Archie Jamwal
 
PPTX
Selection sorting
Himanshu Kesharwani
 
PPT
Arrays
archikabhatia
 
PPTX
Threaded Binary Tree
khabbab_h
 
PDF
Array data structure
maamir farooq
 
Python list
Mohammed Sikander
 
Array in c programming
Mazharul Islam
 
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Selection sorting
Himanshu Kesharwani
 
Threaded Binary Tree
khabbab_h
 
Array data structure
maamir farooq
 

What's hot (20)

PPTX
Linked list
KalaivaniKS1
 
PPTX
Deque and its applications
Jsaddam Hussain
 
PPTX
Queue ppt
SouravKumar328
 
PPTX
Introduction to Array ppt
sandhya yadav
 
PPTX
Stack and its operations
V.V.Vanniaperumal College for Women
 
PPTX
arrays of structures
arushi bhatnagar
 
PPT
Stacks
sweta dargad
 
PPTX
Preprocessor directives in c language
tanmaymodi4
 
PPTX
Linked List
Ashim Lamichhane
 
PPTX
Counting Sort
Faiza Saleem
 
PPTX
Queue - Data Structure - Notes
Omprakash Chauhan
 
PPT
Operator Overloading
Nilesh Dalvi
 
PPTX
Structure in C
Kamal Acharya
 
PDF
Arrays in python
moazamali28
 
PPT
Strings
Nilesh Dalvi
 
PPTX
Arrays in c language
tanmaymodi4
 
PPTX
Function in C program
Nurul Zakiah Zamri Tan
 
PPTX
Doubly Linked List
Ninad Mankar
 
PPTX
Programming in c Arrays
janani thirupathi
 
PDF
Stack
Zaid Shabbir
 
Linked list
KalaivaniKS1
 
Deque and its applications
Jsaddam Hussain
 
Queue ppt
SouravKumar328
 
Introduction to Array ppt
sandhya yadav
 
Stack and its operations
V.V.Vanniaperumal College for Women
 
arrays of structures
arushi bhatnagar
 
Stacks
sweta dargad
 
Preprocessor directives in c language
tanmaymodi4
 
Linked List
Ashim Lamichhane
 
Counting Sort
Faiza Saleem
 
Queue - Data Structure - Notes
Omprakash Chauhan
 
Operator Overloading
Nilesh Dalvi
 
Structure in C
Kamal Acharya
 
Arrays in python
moazamali28
 
Strings
Nilesh Dalvi
 
Arrays in c language
tanmaymodi4
 
Function in C program
Nurul Zakiah Zamri Tan
 
Doubly Linked List
Ninad Mankar
 
Programming in c Arrays
janani thirupathi
 
Ad

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
 
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)

DOC
CBSE Class XII Comp sc practical file
Pranav Ghildiyal
 
PDF
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
rushabhshah600
 
PPTX
Data Structures asdasdasdasdasdasdasdasdasdasd
abdulrahman39ab
 
DOCX
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
PPTX
Queue oop
Gouda Mando
 
PPT
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
PDF
Given below is the code for the question. Since the test files (ment.pdf
aptind
 
PDF
Given below is the code for the question. Since the test files (ment.pdf
aptind
 
PPT
Sparse Matrix and Polynomial
Aroosa Rajput
 
DOCX
C++ file
simarsimmygrewal
 
PDF
a) Write the recursive function in C++ to sort a set of data using M.pdf
nageswara1958
 
DOCX
Qprgs
Ssankett Negi
 
DOCX
Data structure and algorithm lab spiral (1) (4) (1).docx
parkavimannar
 
PPTX
The presention is about the queue data structure
gaurav77712
 
PDF
Implement the Queue ADT using array – based approach. Using C++ prog.pdf
sktambifortune
 
DOC
Ada file
Kumar Gaurav
 
PDF
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
aathiauto
 
PDF
DSC program.pdf
Prof. Dr. K. Adisesha
 
PDF
DATA STRUCTURE USING C & C++
mustkeem khan
 
PDF
DSU C&C++ Practical File Diploma
mustkeem khan
 
CBSE Class XII Comp sc practical file
Pranav Ghildiyal
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
rushabhshah600
 
Data Structures asdasdasdasdasdasdasdasdasdasd
abdulrahman39ab
 
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
Queue oop
Gouda Mando
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
Given below is the code for the question. Since the test files (ment.pdf
aptind
 
Given below is the code for the question. Since the test files (ment.pdf
aptind
 
Sparse Matrix and Polynomial
Aroosa Rajput
 
a) Write the recursive function in C++ to sort a set of data using M.pdf
nageswara1958
 
Data structure and algorithm lab spiral (1) (4) (1).docx
parkavimannar
 
The presention is about the queue data structure
gaurav77712
 
Implement the Queue ADT using array – based approach. Using C++ prog.pdf
sktambifortune
 
Ada file
Kumar Gaurav
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
aathiauto
 
DSC program.pdf
Prof. Dr. K. Adisesha
 
DATA STRUCTURE USING C & C++
mustkeem khan
 
DSU C&C++ Practical File Diploma
mustkeem khan
 

Recently uploaded (20)

PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
Trends in pediatric nursing .pptx
AneetaSharma15
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
Autodock-for-Beginners by Rahul D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Trends in pediatric nursing .pptx
AneetaSharma15
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Autodock-for-Beginners by Rahul D Jawarkar.pptx
Rahul Jawarkar
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 

Queue Implementation Using Array & Linked List