MicrolearnENPTES

Heaps and priority queues

Lesson 12 of 20 · Algo.Micro

Always know the smallest item, even while items keep arriving.

In a min-heap every parent is ≤ its children, so the smallest item is always at the top. It is stored compactly in an array: the children of index i live at 2i+1 and 2i+2.

Check yourself

In a min-heap, where is the smallest item?

Do it in the browser: a real algorithms tool, a short mission and instant feedback. No install.

Start this lesson — free
← Hash tablesBinary search trees →

All lessons · Algo.Micro