Algorithms and Data Structures · Middle · Question 9 of 75
What is a binary heap (min-heap)?
- 1A sorted array that supports O(1) insertion
- ✓Correct answer: A complete binary tree where each parent is no greater than its children
- 3A binary tree where the left child is smaller and the right one larger
Explanation
The smallest element is always at the root, but the rest are only partially ordered. A heap is usually stored in an array: the children of index i are at 2i + 1 and 2i + 2. The left-smaller rule describes a BST.