HeapSort is an efficient comparison-based sorting algorithm that uses a binary heap data structure. It has two main phases:
Time Complexity: O(n log n) in all cases (best, average, and worst).
Space Complexity: O(1) auxiliary space (in-place sorting).