An array-based binary min-heap contains n distinct keys. A key comparison, array access, or swap takes constant time. Choose constant, logarithmic, or linear to complete each statement about the tight worst-case running time as n grows.
- Inspecting the minimum without removing it takes time.
- Searching for an arbitrary key when its index is unknown takes time.
- Decreasing a key and restoring heap order, when its index is supplied, takes time.
- Constructing a heap from an arbitrary array using bottom-up sift-down takes time.
A binary min-heap is stored in a 0-indexed array, so the parent of index i is at index ⌊(i−1)/2⌋. The array currently holds:
3, 7, 5, 12, 9, 8, 10, 15, 14
The key 4 is inserted using the standard method: append it at the end of the array, then sift it up. Give the final index of the key 4, the number of swaps performed, and the value stored at index 4 after the insertion. Answer each as a whole number.