PriorityQueues

PriorityQueues - Priority Queues 4/1/2003 8:51 AM Outline...

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

View Full Document Right Arrow Icon
4/1/2003 8:51 AM Priority Queues 1 Priority Queues $118 IBM 400 Buy $119 IBM 500 Buy IBM IBM $120 300 Sell $122 100 Sell 4/1/2003 8:51 AM Priority Queues 2 Outline and Reading PriorityQueue ADT (§7.1) Total order relation (§7.1.1) Comparator ADT (§7.1.4) Sorting with a priority queue (§7.1.2) Selection-sort (§7.2.3) Insertion-sort (§7.2.3) 4/1/2003 8:51 AM Priority Queues 3 Priority Queue ADT A priority queue stores a collection of items An item is a pair (key, element) Main methods of the Priority Queue ADT ± insertItem (k, o) inserts an item with key k and element o ± removeMin () removes the item with the smallest key Additional methods ± minKey (k, o) returns, but does not remove, the smallest key of an item ± minElement () returns, but does not remove, the element of an item with smallest key ± size (), isEmpty () Applications: ± Standby flyers ± Auctions ± Stock market 4/1/2003 8:51 AM Priority Queues 4 Total Order Relation Keys in a priority queue can be arbitrary objects on which an order is defined Two distinct items in a priority queue can have the same key Mathematical concept of total order relation ± Reflexive property: x x ± Antisymmetric property: x y y x x = y ± Transitive property: x y y z x z 4/1/2003 8:51 AM Priority Queues
Background image of page 1

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

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

Page1 / 2

PriorityQueues - Priority Queues 4/1/2003 8:51 AM Outline...

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

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