0 out of 464 challenges solved
A min heap is a binary tree where the value of each node is less than or equal to the values of its children. Given an array representation of a binary tree, write a function `check_min_heap(arr)` to determine if the array represents a min heap. The array representation of a binary tree follows these rules: - The root node is at index 0. - For a node at index `i`, its left child is at index `2*i + 1` and its right child is at index `2*i + 2`. #### Example Usage ```python [main.nopy] print(check_min_heap([1, 2, 3, 4, 5, 6])) # Output: True print(check_min_heap([2, 3, 4, 5, 10, 15])) # Output: True print(check_min_heap([2, 10, 4, 5, 3, 15])) # Output: False ``` #### Constraints - The input array will have at least one element. - The elements of the array are integers.
def check_min_heap(arr): """ Check if the given array represents a min heap. Args: arr (list): The array representation of a binary tree. Returns: bool: True if the array represents a min heap, False otherwise. """ # Placeholder for the solution pass