The heapsort algorithm has O(n log n) time complexity. But it uses the heap data structure and has O(1) space complexity, why?