2 research outputs found

    A characterization of heaps and its applications

    Get PDF
    AbstractIn this paper we present a new view of a classical data structure, the heap. We view a heap on n elements as an ordered collection of ⌜log2(n + 1)⌝ substructures of sizes 2i with i in {0, …, ⌈log2(n)⌉}. We use the new view in the design of an algorithm for splitting a heap on n elements into two heaps on k and n − k elements, respectively. The algorithm requires O(log2(n)) comparisons, improving the previous bound of O(k) comparisons for all but small values of k, i.e., for k log2(n). We also present a new and conceptually simple algorithm for merging heaps of sizes n and k into one heap of size n + k in O(log(n) ∗ log(k)) comparisons
    corecore