Question DSA-HEAP-0022
EasyIs the array [10, 20, 15, 30, 40] a valid min-heap (index 0 is the root)?
- A.
Only as a max-heap
- B.
Only if it is sorted
- C.
Show answer and explanation
Answer: D
10 ≤ 20 and 10 ≤ 15; 20 ≤ 30 and 20 ≤ 40. Every parent is smaller than its children.