Chapter 14: Queue and Priority Queue Implementations

Slides:



Advertisements
Similar presentations
queues1 Queues Data structures that wait their turn.
Advertisements

Fundamentals of Python: From First Programs Through Data Structures
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.
Chapter 13 Queues and Priority Queues CS Data Structures Mehmet H Gunes Modified from authors’ slides.
© 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.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
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.
Queue, Deque, and Priority Queue Implementations Chapter 11 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
© 2006 Pearson Addison-Wesley. All rights reserved8 A-1 Chapter 8 Queues (slightly modified by Dan Fleck)
© 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++
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++
© 2011 Pearson Addison-Wesley. All rights reserved 8 B-1 Chapter 8 (continued) Queues.
Queue, Deque, and Priority Queue Implementations Chapter 23.
A Bag Implementation that Links Data Chapter 3 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions.
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,
Queues and Priority Queue Implementations Chapter 14 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 7: Queues Data Abstraction & Problem Solving with C++
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
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
CSCI-255 LinkedList.
CS Data Structures Chapter 8 Lists Mehmet H Gunes
Chapter 12: Data Structures
Stacks and Queues.
Processing Data in External Storage
A Bag Implementation that Links Data
Chapter 16 Tree Implementations
Chapter 13 Queues and Priority Queues
Implementations of the ADT Stack
Queue, Deque, and Priority Queue Implementations
Queue, Deque, and Priority Queue Implementations
Queues.
Chapter 4 Link Based Implementations
Arrays and Linked Lists
Chapter 12 Sorted Lists and their Implementations
Chapter 3 Array-Based Implementations
Queue and Priority Queue Implementations
Dictionaries and Their Implementations
CS Data Structures Chapter 17 Heaps Mehmet H Gunes
List Implementations Chapter 9.
CS Data Structures Chapter 17 Heaps Mehmet H Gunes
Chapter 16 Tree Implementations
List Implementations that Use Arrays
A List Implementation That Links Data
Sorted Lists and Their Implementations
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Stack Implementations
Figure 7.1 Some queue operations. Figure 7.1 Some queue operations.
Chapter 7 Implementations of the ADT Stack
Lecture 16 Section 6.2 Thu, Mar 1, 2007
Chapter 8 Queues © 2006 Pearson Addison-Wesley. All rights reserved.
ADT Queue (Array Implementation)
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.
A List Implementation That Links Data
List Implementations that Use Arrays
Queues.
Stack Implementations
A List Implementation that Links Data
Queue, Deque, and Priority Queue Implementations
Presentation transcript:

Chapter 14: Queue and Priority Queue Implementations CS 302 - Data Structures Mehmet H Gunes Modified from authors’ slides

Implementations of the ADT Queue Like stacks, queues can have Array-based or Link-based implementation Can also use implementation of ADT list Efficient to implement Might not be most time efficient as possible © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Implementation That Uses the ADT List An implementation of the ADT queue that stores its entries in a list © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Implementation That Uses the ADT List The header file for the class ListQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Implementation That Uses the ADT List The header file for the class ListQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Implementation That Uses the ADT List The implementation file for the class ListQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Implementation That Uses the ADT List The implementation file for the class ListQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Implementation That Uses the ADT List The implementation file for the class ListQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

A Link-Based Implementation Similar to other link-based implementation One difference … Must be able to remove entries From front From back Requires a pointer to chain’s last node Called the “tail pointer” © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

A Link-Based Implementation A chain of linked nodes with head and tail pointers © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

A Link-Based Implementation The header file for the class LinkedQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

A Link-Based Implementation The header file for the class LinkedQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

A Link-Based Implementation Adding an item to a nonempty queue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

A Link-Based Implementation Removing an item from a queue of more than one item © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

A Link-Based Implementation Removing an item from a queue of more than one item © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

A Link-Based Implementation A circular chain of linked nodes with one external pointer © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation A naive array-based implementation of a queue for which rightward drift can cause the queue to appear full © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation A circular array as an implementation of a queue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation The effect of three consecutive operations on the queue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation front and back as the queue becomes empty and as it becomes full © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation front and back as the queue becomes empty and as it becomes full © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation The header file for the class ArrayQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation The implementation file for the class ArrayQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation The implementation file for the class ArrayQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation The implementation file for the class ArrayQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation The implementation file for the class ArrayQueue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Array-Based Implementation A circular array having one unused location as an implementation of a queue © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

Comparing Implementations Issues Fixed size (array-based) versus dynamic size (link-based) © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Implementation of the ADT Priority Queue A header file for the class SL_PriorityQueue. © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Implementation of the ADT Priority Queue A header file for the class SL_PriorityQueue. © 2017 Pearson Education, Hoboken, NJ.  All rights reserved