notes05 - CSE 2320 Notes 5: Heapsort and Priority Queues...

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

View Full Document Right Arrow Icon
CSE 2320 Notes 5: Heapsort and Priority Queues (Last updated 3/26/12 13:58 A3/P3) Sedgewick 9.1-9.6, 11.4 5.A. (B INARY ) H EAP P ROPERTIES 1. Binary tree. 2. Like a complete tree, but missing some “rightmost” leaves in deepest level. 3. a. Each parent has a priority the priority of its children - maxheap. b. Each parent has a priority the priority of its children - minheap. Common Mapping of a Heap to an Array 1. Subscript 0 is unused. 2. Subscript 1 stores the root of the heap. 3. If it exists, the left child for subscript i is stored at subscript 2 i . 4. If it exists, the right child for subscript i is stored at subscript 2 i +1. 5. Parent of node with subscript i is i 2 ë û .
Background image of page 1

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

View Full DocumentRight Arrow Icon
Aside: Alternate Mapping of a Heap to an Array 1. Subscript 0 stores the root of the heap. 2. If it exists, the left child for subscript i is stored at subscript 2 i + 1. 3. If it exists, the right child for subscript i is stored at subscript 2 i + 2. 4.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

notes05 - CSE 2320 Notes 5: Heapsort and Priority Queues...

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

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