All mock tests are FREE till 31 December — register to save your progress
Unit 7 · Data Structures and Algorithms Paper 2 CS · December 2019

What is the worst case running time of Insert and Extract-min, in an implementation of a priority queue using an unsorted array? Assume that all insertions can be accomodated.

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: A. Θ(1), Θ(n)

Explanation

Insert appends at the end in Θ(1); extract-min must scan all n elements, Θ(n).

More Data Structures and Algorithms questions