Heapsort is a sorting algorithm that uses a binary tree known as a heap. It has a worst-case runtime of O(n log n), making it useful for critical applications. A heap is a balanced, left-justified binary tree where each node's value is greater than or equal to its children. Heapsort inserts values into a heap and then removes the largest value to sort the data.