If you build a heap bottom-up (heapify), most nodes are near the leaves and move only a small distance. The total work across all nodes forms a decreasing series, which sums to O(n). Doing n inserts one-by-one is O(n log n), but bottom-up heapify is O(n).
Advanced answer
Deep dive
Expanding on the short answer — what usually matters in practice:
Context (tags): heap, heapify, complexity, big-o
Complexity: compare typical operations (average vs worst-case).
Invariants: what must always hold for correctness.
When the choice is wrong: production symptoms (latency, GC, cache misses).
Explain the "why", not just the "what" (intuition + consequences).
Trade-offs: what you gain/lose (time, memory, complexity, risk).
Edge cases: empty inputs, large inputs, invalid inputs, concurrency.
Examples
A tiny example (an explanation template):
// Example: discuss trade-offs for "building-a-heap-from-an-array:-why-can-it-be-o(n"
function explain() {
// Start from the core idea:
// If you build a heap bottom-up (heapify), most nodes are near the leaves and move only a sm
}
Common pitfalls
Too generic: no concrete trade-offs or examples.
Mixing average-case and worst-case (e.g., complexity).