What is the worst-case time complexity of inserting an element in a heap of…

2026

What is the worst-case time complexity of inserting an element in a heap of size n ?

  1. A.

    O(1)

  2. B.

    O(log n)

  3. C.

    O(n)

  4. D.

    O(n log n)

Attempted by 101 students.

Show answer & explanation

Correct answer: B

The worst-case time complexity of inserting an element in a heap of size n is O(log n).

Explore the full course: Niacl Ao It Specialist