Download presentation
Presentation is loading. Please wait.
Published byNorah Simmons Modified over 8 years ago
1
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem Solving with JAVA: Walls and Mirrors Carrano / Prichard Queues
2
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Create an empty queue. Determine whether a queue is empty. Add a new item to the queue. Remove from the queue the item that was added earliest. Remove all the items from the queue. Retrieve from the queue the item that was added earliest. ADT Queue Operations
3
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.1 Some queue operations
4
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.2 The results of inserting a string into both a queue and a stack
5
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Array-based Implementation Reference-based Implementation Comparing Implementations Implementations of the ADT Queue
6
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.3a A reference-based implementation of a queue: a) a linear linked list with two external references; b) a circular linear linked list with one external reference
7
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.3b A reference-based implementation of a queue: a) a linear linked list with two external references; b) a circular linear linked list with one external reference
8
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.4 Inserting an item into a nonempty queue
9
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.5 Inserting an item into an empty queue: a) before insertion; b) after insertion
10
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.6 Deleting an item from a queue of more than one item
11
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.7 a) A naive array-based implementation of a queue; b) rightward drift can cause the queue to appear full
12
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.8 A circular implementation of a queue
13
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.9 The effect of some operations of the queue in Figure 7-8
14
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.10a a) front passes back when the queue becomes empty
15
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.10b b) back catches up to front when the queue becomes full
16
Data Abstraction and Problem Solving with JAVA Walls and Mirrors; Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Figure 7.11 A more efficient circular implementation: a) a full queue; b) an empty queue
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.