📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    A data analysis task requires repeatedly extracting the

    element with the highest priority from a collection. Which heap operation is used for this, and what is its typical time complexity?
    A Insert, O(log n) Correct Answer Incorrect Answer
    B Delete, O(1) Correct Answer Incorrect Answer
    C Extract-Max, O(log n) Correct Answer Incorrect Answer
    D Peek, O(n) Correct Answer Incorrect Answer
    E Heapify, O(n) Correct Answer Incorrect Answer

    Solution

    Extracting the maximum (or minimum in a min-heap) element involves removing the root, replacing it with the last element, and then "bubbling down" (heapifying down) to restore the heap property. This operation takes O(log n) time.

    Practice Next
    ask-question