Algorithms and Data Structures · Middle · Question 10 of 75

What are the costs of the main operations of a binary heap?

Explanation

The minimum sits at the root. Insert adds to the end and "sifts up"; extraction moves the last element to the root and "sifts down". Both walk one path of height log n.

Further reading

Problem with a question

Algorithms and Data Structures · Middle · question 10

Test yourself

Take the Algorithms and Data Structures · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz