AI engineering glossary · Data structures algorithms

What is heapify?

Heapify (also called sift down, sift up): The procedure of turning an unordered array into a valid heap, or of restoring the heap property after one element changes, by moving elements down (sift down) or up. Building a heap from n items this way takes O(n) time.

Level: advancedTopic: Data structures algorithms

Heapify: an example

Turning [9, 4, 7, 1] into a min-heap by sifting down from the last parent yields [1, 4, 7, 9].

Related terms

More Data structures algorithms terms

Where you learn it

Heapify is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.