Visit for more Learning Resources

Slides:



Advertisements
Similar presentations
STACKS & QUEUES. Stacks Abstract data types An abstract data type (ADT) is an abstraction of a data structure An ADT specifies : –Data stored –Operations.
Advertisements

Chapter 6 Queues and Deques.
Data Structures Lecture 13: QUEUES Azhar Maqsood NUST Institute of Information Technology (NIIT)
CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
ADT Queue 1. What is a Queue? 2. STL Queue 3. Array Implementation of Queue 4. Linked List Implementation of Queue 5. Priority Queue.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 18 Stacks.
Data Structure Dr. Mohamed Khafagy.
Queue RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
Queues and Priority Queues
Chapter 13 Queues and Priority Queues CS Data Structures Mehmet H Gunes Modified from authors’ slides.
CS 206 Introduction to Computer Science II 10 / 20 / 2008 Instructor: Michael Eckmann.
Main Index Contents 11 Main Index Contents Model for a Queue Model for a Queue The Queue The Queue ADTQueue ADT (3 slides) Queue ADT Radix Sort Radix Sort.
1 Queues CPS212 Gordon College. 2 Introduction to Queues A queue is a waiting line – seen in daily life –Real world examples – toll booths, bank, food.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition Chapter 18: Stacks and.
 Chapter 8 introduces the queue data type.  Several example applications of queues are given in that chapter.  This presentation describes the queue.
Queues and Priority Queues
Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04.
Stacks and Queues Introduction to Computing Science and Programming I.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 4 Prepared by İnanç TAHRALI.
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 What is a queue?. Queues A queue is similar to waiting in line for a service, e.g., at the bank, at the bathroom –The first item put on the queue.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Implementation of QUEUE For more notes and topics visit: eITnotes.com.
1 Data Structures CSCI 132, Spring 2016 Notes_ 5 Stacks.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 18: Stacks and Queues.
Review Array Array Elements Accessing array elements
Cpt S 122 – Data Structures Abstract Data Types
Chapter 18: Stacks and Queues.
G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY
Data Structure By Amee Trivedi.
Queues.
Chapter 15 Lists Objectives
Queues Queues Queues.
CSCE 3110 Data Structures & Algorithm Analysis
Stacks A stack is a data structure that is similar in spirit to a pile of cafeteria trays. Think about the trays in the dining halls: when the dining staff.
Introduction to Data Structure
CMSC 341 Lecture 5 Stacks, Queues
Queues 11/9/2018 6:28 PM Queues 11/9/2018 6:28 PM Queues.
Stacks Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Stacks, Queues, and Deques
Chapter 19: Stacks and Queues.
Queues 11/16/2018 4:18 AM Queues 11/16/2018 4:18 AM Queues.
Queues 11/16/2018 4:19 AM Queues 11/16/2018 4:19 AM Queues.
Stacks and Queues.
Stacks, Queues, and Deques
CSC 143 Queues [Chapter 7].
Queues 12/3/2018 Queues © 2014 Goodrich, Tamassia, Goldwasser Queues.
Queues 12/30/2018 9:24 PM Queues 12/30/2018 9:24 PM Queues.
Introduction to Programming
Stack A data structure in which elements are inserted and removed only at one end (called the top). Enforces Last-In-First-Out (LIFO) Uses of Stacks Evaluating.
Data Structures and Algorithms for Information Processing
Abstract Data Type Abstract Data Type as a design tool
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Priority Queues & Heaps
Queues Jyh-Shing Roger Jang (張智星)
QUEUE Visit for more Learning Resources Free Powerpoint Templates.
CE 221 Data Structures and Algorithms
Using a Queue Chapter 8 introduces the queue data type.
Using a Queue Chapter 8 introduces the queue data type.
Stacks, Queues, and Deques
Using a Queue Chapter 8 introduces the queue data type.
CSCS-200 Data Structure and Algorithms
Using a Queue Chapter 8 introduces the queue data type.
Stacks and Queues.
Presented by : Aman Gupta PGT CS KV No.1, Narimedu, Madurai
Chapter 6 – Queues and Deques
Lecture 9: Stack and Queue
DATA STRUCTURES IN PYTHON
Data Structures & Programming
Presentation transcript:

Visit for more Learning Resources QUEUE Visit for more Learning Resources

The Queue Operations Front Rear A queue is like a line of people waiting for a bank teller. The queue has a front and a rear. $ $ When you think of a computer science queue, you can imagine a line of people waiting for a teller in a bank. The line has a front (the next person to be served) and a rear (the last person to arrive. Front Rear

The Queue Operations Front Rear New people must enter the queue at the rear. The C++ queue class calls this a push, although it is usually called an enqueue operation. $ $ Don’t ask me why the C++ STL used the name push. It only confuses matters with a stack. In any case, when a new item enters a queue, it does so at the rear. Front Rear

The Queue Operations Front Rear When an item is taken from the queue, it always comes from the front. The C++ queue calls this a pop, although it is usually called a dequeue operation. $ $ When an item is removed from a queue, the removal occurs at the front. Front Rear

The Queue Class The C++ standard template library has a queue template class. The template parameter is the type of the items that can be put in the queue. template <class Item> class queue<Item> { public: queue( ); void push(const Item& entry); void pop( ); bool empty( ) const; Item front( ) const; … }; These are the four most common queue operations. The empty function tells you whether the queue has any items at the moment. The front operation returns the item at the front of the queue (without removing it from the queue).

Array Implementation A queue can be implemented with an array, as shown here. For example, this queue contains the integers 4 (at the front), 8 and 6 (at the rear). [ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . . . Just like our stack implementation in the previous chapter, one way to implement a queue is to store the elements in an array. 4 8 6 An array of integers to implement a queue of integers We don't care what's in this part of the array.

Array Implementation size The easiest implementation also keeps track of the number of items in the queue and the index of the first element (at the front of the queue), the last element (at the rear). 3 first last 2 The easiest implementation also keeps track of three numbers. The size could be as small as zero or as large as the number of items in the array. The index of the front element is stored in the first member variable. The front item in the queue is at that index of the array. The next item is after the first one and so on until the rear of the queue that occurs at the index stored in a member variable called last. [ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . . . 4 8 6

For more detail contact us A Dequeue Operation size When an element leaves the queue, size is decremented, and first changes, too. 2 first 1 last 2 This shows how the member variables change when an item leaves the queue. [ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . . . 4 8 6 For more detail contact us