Which of the following best describes the min-heap property for a binary heap?
Think about which node should have the smallest value in a min-heap.
In a min-heap, the parent node is always smaller than or equal to its children, ensuring the smallest element is at the root.
In a max-heap, what can be said about the value of the root node compared to other nodes?
Consider the heap property that defines max-heaps.
The max-heap property ensures the root node has the largest value, as every parent is greater than or equal to its children.
Given the following array representing a binary heap: [10, 15, 20, 17, 25], which heap property does it violate if any?
Array representation: [10, 15, 20, 17, 25]
Check if parents are smaller or larger than their children according to min-heap or max-heap rules.
In this array, each parent node is less than or equal to its children, so it satisfies the min-heap property and does not violate min-heap or max-heap properties.
Which statement correctly compares min-heaps and max-heaps?
Think about the shape and ordering rules of heaps.
Both min-heaps and max-heaps are complete binary trees. The difference lies in whether parents are smaller (min-heap) or larger (max-heap) than their children.
When inserting a new element into a min-heap, which of the following best describes the process to maintain the min-heap property?
Consider where new elements are added and how to restore heap order.
New elements are added at the last position (bottom-right) and then swapped upwards (heapify up) to maintain the min-heap property.