The distribution of keys in a binary heap
We show that the k th smallest element in a large heap is at expected depth ≤log k. Simulation results indicate that this bound is tight, and that the variance of the depth is no more than 0.8, independent of k.
This leads to a simple algorithm for actually finding the k th smallest element that appears to run in O(k) expected time, which would improve the previous best-known bound of O(klog k). We prove an Ω(klog k) lower bound for worst case running time of any algorithm to solve this problem.
Unable to display preview. Download preview PDF.
- Knuth, D.E., The Art of Computer Programming, Vol. 3: Sorting and Searching (Addison-Wesley, Reading, MA, 1973).Google Scholar
- Navlakha, J.K., "Finding the k-th largest element in a large heap in O (k log log n) time", Proceedings of the 1982 Conference of Information Science and Systems, Princeton, (1982) 66–69.Google Scholar
- Williams, J. W. J., Algorithm 232, Communications of the ACM, 7, 6 (1964), 347–348.Google Scholar