Question DSA-HEAP-0002
EasyWhat is the time complexity of inserting into a binary heap?
- A.
O(log n)
- B.
O(n)
- C.
Show answer and explanation
Answer: A
The new element is added at the end and bubbles up at most the height of the tree.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Heaps and Priority Queues question
What is the time complexity of inserting into a binary heap?
O(log n)
O(n)
Answer: A
The new element is added at the end and bubbles up at most the height of the tree.
O(n log n)
O(1)