{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

PQ - CSE 4101/5101 Prof Andy Mirzaian Priority Queues...

Info icon This preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 4101/5101 Priority Queues Prof. Andy Mirzaian
Image of page 1

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

View Full Document Right Arrow Icon
TOPICS Ø Priority Queues Ø Leftist Heaps Ø Skew Heaps Ø Binomial Heaps Ø Fibonacci Heaps Ø Recent Developments 2
Image of page 2
References: [CLRS 2nd edition] chapters 19, 20 or [CLRS 3rd edition] chapter 19 & Problem 19-2 (pp:527-529) Lecture Notes 4, 5 AAW animations 3
Image of page 3

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

View Full Document Right Arrow Icon
Priority Queues 4
Image of page 4
Basic Priority Queues § Each item x has an associated priority denoted key[x]. § Item priorities are not necessarily distinct and may be time varying. § A Priority Queue Q is a set of prioritized data items that supports the following basic priority queue operations: Insert(x,Q): insert (new) item x into Q. (Duplicate priorities allowed.) DeleteMin(Q): remove and return the minimum key item from Q. § Notes: 1. Priority Queues do not support the Dictionary Search operation. 2. DeleteMin for min-PQ: the lower the key the higher the priority. 3. DeleteMax for max-PQ: the higher the key the higher the priority. 4. More PQ operations shortly. § Example: An ordinary queue can be viewed as a priority queue where the priority of an item is its insertion time. 5
Image of page 5

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

View Full Document Right Arrow Icon
HEAP § Heap Ordered Tree: Let T be a tree that holds one item per node. T is (min-) heap-ordered iff nodes x root(T): key[x] key[parent(x)]. 10 40 14 28 18 36 -  super-root § [ Note: Any subtree of a heap-ordered tree is heap-ordered.] § Heap: a forest of one or more node-disjoint heap-ordered trees. 20 40 22 60 24 32 56 38 56 76 46 52 6
Image of page 6
Some Applications § Sorting and Selection. § Scheduling processes with priorities. § Priority driven discrete event simulation. § Many Graph and Network Flow algorithms, e.g., Prim’s Minimum Spanning Tree algorithm, Dijkstra’s Shortest Paths algorithm, Max Flow, Min-Cost Flow, Weighted Matching, … § Many problems in Computational Geometry, e.g., plane sweep (when not all events are known in advance). 7
Image of page 7

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

View Full Document Right Arrow Icon
More Heap Operations Mergeable Heap Operations: MakeHeap(e): generate and return a heap that contains the single item e with a given key key[e]. Insert(e,H): insert (new) item e, with its key key[e], into heap H. FindMin(H): return the minimum key item from heap H. DeleteMin(H): remove and return the minimum key item from heap H. Union(H1, H2): return the heap that results from replacing heaps H1 and H2 by their disjoint union H1  H2. (This destroys H1 and H2.) DecreaseKey(x,K,H): Given access to node x of heap H with key[x] > K, decrease Key[x] to K and update heap H. Delete(x,H): Given access to node x of heap H, remove the item at node x from Heap H. 8
Image of page 8
Beyond Standard Heap Williams[1964]: Array based binary heap (for HeapSort). See [CLRS ch 6]. Time complexities of mergeable heap operations on this structure are: O(1) MakeHeap(e), FindMin(H). O(log n) Insert(e,H), DeleteMin(H) (n = |H|) O(n) Union(H1, H2) (n = |H1| + |H2|) Insert(e,H) H’  MakeHeap(e) H  Union(H, H’) end r L R DeleteMin(H) r  root[H] if r = nil then return error MinKey  Key[r] root[H]  Union(left[r], right[r]) return MinKey end Insert and DeleteMin via Union in a pointer -based (binary tree) heap: Can we improve Union in order to improve both Insert & DeleteMin?
Image of page 9

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

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern