Heap-sort runs in:
Heaps
Heaps (Goodrich): the priority queue ADT and PQ-sorting, heap-order and completeness, height, insertion with upheap, removal with downheap, heap-sort, array-based heaps, merging, and bottom-up construction in O(n).
How to read this page
Every original slide is shown unchanged. Yellow marks on a slide point to a numbered note: hover or tap a mark to jump to its note, and hover a note to see its marks. Questions tagged Past exam appeared on a real paper; Prediction questions are likely angles, not confirmed. Pick an answer to each question: a wrong pick tells you why it is wrong, so you can try again.
All 27 slides
- 1 Part-D2
- 2 Recall Priority Queue ADT ( § 7.1.3)
- 3 Recall Priority Queue Sorting ( § 7.1.4)
- 4 aheap the node
- 5 Slide 5
- 6 Slide 6
- 7 Slide 7
- 8 a.si wisias is isan
- 9 a r
- 10 Slide 10
- 11 Height of a Heap ( § 7.3.1)
- 12 Heaps and Priority Queues
- 13 Insertion into a
- 14 Upheap
- 15 Removal from a Heap ( § 7.3.3)
- 16 Slide 16
- 17 Downheap
- 18 Updating the Last Node
- 19 Heap-Sort ( § 2.4.4)
- 20 Vector-based Heap
- 21 Merging Two Heaps
- 22 Bottom-up Heap Construction ( § 2.4.3)
- 23 Example
- 24 Example (contd.)
- 25 Example (contd.)
- 26 Example (end)
- 27 Analysis
Downheap
Notes
Downheap after removeMin: swap down with the smaller child → O(log n).
Heap-Sort ( § 2.4.4)
Exam angle
Bottom-up Heap Construction ( § 2.4.3)
Exam angle
Bottom-up heap construction takes O(n log n) and cannot be faster.
- It is O(n).