23_Queues - Data Structures and Algorithms I Click to edit...

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style © 2009 Dr. Tim Data Structures and Algorithms I The Queue Dr. Tim Margush University of Akron © 2009
Background image of page 1

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

View Full DocumentRight Arrow Icon
© 2009 Dr. Tim Goals Be able to describe the basic organization and operations for a queue ADT Know the tradeoffs for common implementations of a queue Understand the queue variations: deques and priority queues Be able to use a queue to solve problems
Background image of page 2
© 2009 Dr. Tim Queue A FIFO Collection First in, First out The oldest item in the collection is referred to as the front item The new items are added at the rear (or end) The operation to add is enqueue The operation to remove is dequeue
Background image of page 3

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

View Full DocumentRight Arrow Icon
© 2009 Dr. Tim Queue Interface public interface Queue<E>{ void enqueue(E anEntry); E dequeue(); E getFront(); boolean isEmpty(); void clear(); }
Background image of page 4
© 2009 Dr. Tim Java.util's Queue Interface Implemented by LinkedList and PriorityQueue (among others) public interface java.util.Queue<E> extends Collection<E>, Iterable<E>{ boolean offer(E anEntry); //returns true if added E poll(); //returns null if empty E remove(); //throws exception if empty E peek(); //null if empty E element(); //exception if empty }
Background image of page 5

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

View Full DocumentRight Arrow Icon
© 2009 Dr. Tim Waiting Lines Simulations often model arrivals and departures Arrivals are processed in FIFO order A queue is the natural structure to hold items awaiting processing Discrete Event simulation Events are given timestamps The simulator processes the event with the smallest time stamp
Background image of page 6
© 2009 Dr. Tim Traffic Light Events Light change Vehicle arrival Placed in queue Vehicle departure Removed from queue Accident Statistics Waiting time
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

23_Queues - Data Structures and Algorithms I Click to edit...

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

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