Heapsort is a sorting algorithm with average-case time complexity of O(n log n). It works by first constructing a max-heap from the input array and then extracting elements from the heap and placing them in sorted order in the array. The key procedures are MAX-HEAPIFY, which maintains the heap property by floating elements down the heap, and BUILD-MAX-HEAP, which constructs a max-heap from an unsorted array in linear time O(n) by calling MAX-HEAPIFY on successive subtrees.