Practice mode Data Structures

Which data structure is commonly used to implement a priority queue efficiently?

Correct answer C. Binary heap

Explanation

A binary heap supports insert and remove-max (or remove-min) in O(log n) time and peek in O(1), which makes it the standard priority queue implementation; Python's heapq and C++ std::priority_queue both use one. An unsorted linked list gives O(1) insert but O(n) removal, and a sorted one reverses that trade-off, so neither is efficient for both operations.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.