Overlapping Processing and I/O: Heapsort
Heapsort can be combined with reading from the disk and writing to the disk as follows:
- The heap can be built while reading the file.
- Sorting can be done while writing to the file.
Heaps show certain similarities with selection trees, but they have a somewhat looser structure.
Heaps have three important properties:
- Each node has a single key and that key is greater than or equal to the key at its parent node.
- A Heap is a complete binary tree.
- Storage can be allocated sequentially as an array with left and right children of node i located at index 2i and 2i+1 respectively. ==> Pointers are unnecessary.