How is a Heap represented in an Array?

Updated Apr 28, 2026

Short answer

For index i, left child is 2i+1, right is 2i+2, and parent is (i-1)/2.

Deep explanation

Heaps and Maps are fundamental for optimization. For index i, left child is 2i+1, right is 2i+2, and parent is (i-1)/2. Heaps are used for priority management, while Maps provide constant-time data retrieval.

Real-world example

Priority queues in operating systems.

Common mistakes

  • Confusing a Heap with a sorted array.

Follow-up questions

  • Is a Heap a sorted structure?

More Heaps and Maps interview questions

View all →