Queues and Priority Queue Implementations Chapter 14 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.

Slides:



Advertisements
Similar presentations
Lists Chapter 8 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Advertisements

CS Data Structures II Review COSC 2006 April 14, 2017
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 7 Queues. © 2005 Pearson Addison-Wesley. All rights reserved7-2 The Abstract Data Type Queue A queue –New items enter at the back, or rear, of.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
A Bag Implementation that Links Data Chapter 3 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Queues and Priority Queues
Chapter 13 Queues and Priority Queues CS Data Structures Mehmet H Gunes Modified from authors’ slides.
CS Data Structures Chapter 8 Lists Mehmet H Gunes
© 2006 Pearson Addison-Wesley. All rights reserved8-1 Chapter 8 Queues CS102 Sections 51 and 52 Marc Smith and Jim Ten Eyck Spring 2008.
Queue, Deque, and Priority Queue Implementations Chapter 24 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
Cmpt-225 Queues. A queue is a data structure that only allows items to be inserted at the end and removed from the front Queues are FIFO (First In First.
Chapter 7 Queues. © 2005 Pearson Addison-Wesley. All rights reserved7-2 The Abstract Data Type Queue A queue –New items enter at the back, or rear, of.
Sorted Lists and Their Implementations Chapter 12 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 3 Array-Based Implementations CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Queue, Deque, and Priority Queue Implementations Chapter 11 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Data Abstraction: The Walls
Queues and Priority Queues
Implementations of the ADT Stack Chapter 7 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 6 Stacks CS Data Structures Mehmet H Gunes Modified from authors’ slides.
© 2006 Pearson Addison-Wesley. All rights reserved8 A-1 Chapter 8 Queues (slightly modified by Dan Fleck)
Trees Chapter 15 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Algorithm Efficiency Chapter 10 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
© 2006 Pearson Addison-Wesley. All rights reserved8 A-1 Chapter 8 Queues.
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 7: Queues Data Abstraction & Problem Solving with C++
Tree Implementations Chapter 16 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
The Abstract Data Type Queue A queue New items enter at the back, or rear, of the queue Items leave from the front of the queue First-in, first-out (FIFO)
Chapter 8 Queues. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 The Abstract Data Type Queue A queue –New items enter at the back, or rear, of.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 7: Queues Data Abstraction & Problem Solving with C++
A Heap Implementation Chapter 26 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Heaps Chapter 17 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
C++ Classes C++ Interlude 1 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Graphs. Contents Terminology Graphs as ADTs Applications of Graphs.
Data Abstraction and Problem Solving with C++ Walls and Mirrors, Third Edition, Frank M. Carrano and Janet J. Prichard ©2002 Addison Wesley CHAPTER 4 Linked.
Queue, Deque, and Priority Queue Implementations Chapter 23.
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.
Array-Based Implementations Chapter 3 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 7 A Queues. © 2004 Pearson Addison-Wesley. All rights reserved7 A-2 The Abstract Data Type Queue A queue –New items enter at the back, or rear,
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 7: Queues Data Abstraction & Problem Solving with C++
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
Chapter 4 Link Based Implementations
Link Based Implementations
Queues Chapter 8 (continued)
Data Abstraction & Problem Solving with C++
CC 215 Data Structures Queue ADT
Stacks and Queues.
A Bag Implementation that Links Data
Chapter 16 Tree Implementations
Implementations of the ADT Stack
Queue, Deque, and Priority Queue Implementations
Queue, Deque, and Priority Queue Implementations
Chapter 4 Link Based Implementations
Queue and Priority Queue Implementations
Chapter 14: Queue and Priority Queue Implementations
List Implementations Chapter 9
CS Data Structures Chapter 17 Heaps Mehmet H Gunes
List Implementations Chapter 9.
Sorted Lists and Their Implementations
Figure 7.1 Some queue operations. Figure 7.1 Some queue operations.
Array-Based Implementations
Chapter 8 Queues © 2006 Pearson Addison-Wesley. All rights reserved.
Queues cont. Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
Queues and Priority Queue Implementations
Queues Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
Queues.
Stack Implementations
A List Implementation that Links Data
Queue, Deque, and Priority Queue Implementations
Presentation transcript:

Queues and Priority Queue Implementations Chapter 14 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Content Implementations of the ADT Queue An Implementation of the ADT Priority Queue Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

An Implementation That Uses the ADT List View Listing 14-1 header for class ListQueueListing 14-1 Note implementation, Listing 14-2Listing 14-2 FIGURE 14-1 An implementation of the ADT queue that stores its entries in a list.htm code listing files must be in the same folder as the.ppt files for these links to work Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Link-Based Implementation FIGURE 14-1 An implementation of the ADT queue that stores its entries in a list Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Link-Based Implementation FIGURE 14-3 A circular chain of linked nodes with one external pointer Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Link-Based Implementation View header file for class LinkedQueue, Listing 14-3 Listing 14-3 The enqueue method to insert a new node Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Link-Based Implementation FIGURE 14-4 Adding an item to a nonempty queue Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Link-Based Implementation FIGURE 14-5 Adding an item to an empty queue: (a) before enqueue; (b) after enqueue Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Link-Based Implementation Definition for the method enqueue Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Link-Based Implementation Definition of the method dequeue Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Link-Based Implementation FIGURE 14-6 Removing an item from a queue of more than one item Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

A Link-Based Implementation FIGURE 14-6 Removing an item from a queue of more than one item Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

An Array-Based Implementation Possible (naïve) definition Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

An Array-Based Implementation FIGURE 14-7 (a) A naive array-based implementation of a queue; (b) rightward drift can cause the queue to appear full Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

An Array-Based Implementation FIGURE 14-8 A circular array as an implementation of a queue Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

An Array-Based Implementation FIGURE 14-9 The effect of three consecutive operations on the queue in Figure 14-8 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

An Array-Based Implementation FIGURE (a) front passes back when the queue becomes empty; Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

An Array-Based Implementation FIGURE (b) back catches up to front when the queue becomes full Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

An Array-Based Implementation The header file for the class ArrayQueue, Listing 14-4 Listing 14-4 View implementation file, Listing 14-5Listing 14-5 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Variation of Circular Queue FIGURE A more time-efficient circular implementation: (a) a full queue; (b) an empty queue Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Implementation of the ADT Priority Queue View header file, Listing 14-6Listing 14-6 Note add and remove functions Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

End Chapter 14 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013