Heap Sort
Learn Heap Sort (Heap, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Sorting by Repeated Extraction The conceptual core of Heap Sort: put everything into a heap, then repeatedly extract the minimum (or maximum) - since each extraction always removes the current smallest remaining element, the extraction ORDER is automatically sorted. A PriorityQueue makes this trivial to express, though the in-place array version (covered under Sorting) avoids its O(n) extra space.