Queues FIFO Enqueue Dequeue Peek.

Slides:



Advertisements
Similar presentations
Stacks, Queues, and Linked Lists
Advertisements

Queues1 Part-B2 Queues. Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions follow the first-in first-out scheme.
COSC 1P03 Data Structures and Abstraction 9.1 The Queue Whenever you are asked if you can do a job, tell 'em, "Certainly, I can!" Then get busy and find.
1 Stack and Queue. 2 Stack In Out ABCCB Data structure with Last-In First-Out (LIFO) behavior.
1 Queues – Chapter 3 A queue is a data structure in which all additions are made at one end called the rear of the queue and all deletions are made from.
Queues CS-212 Dick Steflik. Queues First In, First Out operation – FIFO As items are added they are chronologically ordered, items are removed in their.
Data Structures for Media Queues. Queue Abstract Data Type Queue Abstract Data Type Sequential Allocation Sequential Allocation Linked Allocation Linked.
1 CSC 211 Data Structures Lecture 22 Dr. Iftikhar Azim Niaz 1.
 Abstract Data Type Abstract Data Type  What is the difference? What is the difference?  Stacks Stacks  Stack operations Stack operations  Parsing.
Queue RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
Queues. What is a queue? First-in first-out data structure (FIFO) New objects are placed at rear Removal restricted to front Examples?
Queues. What is a queue? First-in first-out data structure (FIFO) New objects are placed at rear Removal restricted to front Examples?
Queue using an array. .head.tail Pointers head and tail always point to the first empty slot before or after elements in the list. Thus, initially they.
Queues.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation – FIFO As items are added they are chronologically ordered, items are removed.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA, Dc. Sc. & Engg.
Queue 1 Operations on Queues A Dequeue Operation An Enqueue Operation Array Implementation Link list Implementation Examples.
1 Chapter 7 Stacks and Queues. 2 Stack ADT Recall that ADT is abstract data type, a set of data and a set of operations that act upon the data. In a stack,
Queue FIFO (First In First Out) Java Doc peek, element offer poll, add
Lecture7: Queue Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Lab 7 Queue ADT. OVERVIEW The queue is one example of a constrained linear data structure. The elements in a queue are ordered from least recently added.
Chapter 8 Queue I CS Data Structures I COSC2006 April 24, 2017
Stack Overview. Stack Stack ADT Basic operations of stack – Pushing, popping etc. Implementations of stacks using – array – linked list.
Cousin of the Stack.  An abstract data type (container class) in which items are entered at one end and removed from the other end  First In First.
Introduction Queue is a linear Data Structure in which the operations are performed based on FIFO (First In First Out) principle.
Computer Science Department Data Structures and Algorithms Queues Lecture 5.
Lecture 20 Stacks and Queues. Stacks, Queues and Priority Queues Stacks – first-in-last-out structure – used for function evaluation (run-time stack)
1 Joe Meehean. 2  empty is the queue empty  size  enqueue (add) add item to end of queue  dequeue (remove) remove and return item at front of queue.
Give Eg:? Queues. Introduction DEFINITION: A Queue is an ordered collection of element in which insertions are made at one end and deletions are made.
COSC 2P03 Week 21 Stacks – review A Last-In First-Out (LIFO) structure Basic Operations: –push : insert data item onto top of stack –pop : remove data.
 In general, Queue is line of person waiting for their turn at some service counter like ticket window at cinema hall, at bus stand or at railway station.
Circular Queues Maitrayee Mukerji. Queues First In – First Out (FIFO) The first element to be inserted is the first one to be retrieved Insertion at one.
© 2004 Goodrich, Tamassia Queues. © 2004 Goodrich, Tamassia Stacks2 The Queue ADT The Queue ADT stores arbitrary objects Insertions and deletions follow.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Abstract Data Types Queues Dale Roberts, Lecturer
What is a Queue? Queue is a linear data structure in which the insertion and deletion operations are performed at two different ends. In a queue data structure,
Unit-3 Queues-operations, array and linked representations. Circular Queue operations, Dequeues, applications of queue.
CS505 Data Structures and Algorithms
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
Chapter 15 Lists Objectives
Queue data structure.
Stack and Queue APURBO DATTA.
Priority Queue.
QUEUE.
CSCE 3110 Data Structures & Algorithm Analysis
Stack and Queue.
Data Structures and Database Applications Queues in C#
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
Queue, Deque, and Priority Queue Implementations
Queues.
DATA STRUCTURE QUEUE.
אחסון (אירגון) מידע DATA DATA DATA Link Link Link … …
Queues 12/3/2018 Queues © 2014 Goodrich, Tamassia, Goldwasser Queues.
18.5 Linked Queues Like a stack, a queue can be implemented using pointers and nodes Allows dynamic sizing, avoids issue of wrapping indices NULL front.
Queues 3/9/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
ADT list.
Queues A first-in, first-out or FIFO data structure.
Stacks and Queues 1.
Queues Jyh-Shing Roger Jang (張智星)
Stacks and Queues.
Lecture 16 Stacks and Queues CSE /26/2018.
Stacks LIFO C C B B B B A A A A A Push (A) Push (B) Push (C) Pop Pop.
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
CSCS-200 Data Structure and Algorithms
Data Structures – Week #4
Lecture 16 Stacks and Queues CSE /26/2018.
Queues Dr. Anwar Ghani Lecture 06: Queue Data Structures
Data Structures & Programming
Presentation transcript:

Queues FIFO Enqueue Dequeue Peek

Array-based implementation

Linked List-based implementation struct QUEUE{ int dann; QUEUE *next; }; QUEUE* front=NULL; QUEUE* rear=NULL;

Operations Placing an item at the back of the queue void Enqueue(int a) {QUEUE *q; q=new QUEUE; if (front==NULL) front=q; else rear->next=q; q->dann=a; rear=q; rear-> next =NULL; }

Removing the item from the queue int Dequeue(void) {QUEUE *q; int temp=-1; if (!front) cout << "\nQueue is empty"; else {temp=front->dann; q=front-> next; delete front; front=q; } return temp;

Retrieving the item at the front of the queue int Peek(void) {int temp; if (!front) { cout << "\nQueue is empty"; return -1; } temp=front->dann; return temp;

Queue applications

Priority Queue front front front A D B 1 F 1 C 2 E 2 G 2 NULL

Deques (double-ended queue) Two types of deques: 1. Input restricted deque (Insertion at one end) 2. Output restricted deque (Deletion at one end) A B C D F E G D B A C F E