14 - CMPSCI 187: Programming With Data Structures Lecture...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPSCI 187: Programming With Data Structures Lecture 14: The Queue ADT and Breadth-First Search 11 October 2011
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Queue ADT and Breadth-First Search • Stacks, Queues, and Priority Queues • Using Queues For Timesharing • Other Uses for Queues • The Queue ADT’s: L&C’s QueueADT and Java’s Queue Interface • General Search • Project 4: Breadth-First Search in the Maze • Recovering the Path in Project 4
Background image of page 2
Stacks, Queues, and Priority Queues • When I hold ofFce hours, many students come to see me and I can concentrate on only one at a time. This is typical of real-world computing situations -- I am a server with multiple clients , and I need a protocol telling which ones to serve and when. • A queue is the most typical way to handle such a situation. (“Queue” is the British usage for what Americans more often call a “line”, as in a supermarket or a bank -- it is the ±rench word for “tail”.) If I keep the waiting students in a queue, when I Fnish with one student I turn to the one who has been waiting the longest. • If I instead turned to the student with the most urgent problem, or the student I liked the best, I would be operating a priority queue . If I turned to the student who had been waiting the least time, I would be operating a stack. (Suppose, for example, that I put the current student on hold whenever a new one came in, and went back to the latest-interrupted student when I Fnished.)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Using Queues For Timesharing • What I actually do in my ofFce hours is similar to the practice of timesharing , the most common way to have a server handle multiple clients. • I keep a queue, and when I have been talking to a particular student for long
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/22/2011 for the course COMPSCI 187 taught by Professor Barrington during the Fall '11 term at UMass (Amherst).

Page1 / 10

14 - CMPSCI 187: Programming With Data Structures Lecture...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online