测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 881 字符 |
模型生成的代码 (881 字符)
def check_min_heap(arr):
"""
Check if the given array represents a min heap.
A min heap is a complete binary tree where the value of each node
is less than or equal to the values of its children. In a 0-indexed
array representation, children of node at index i are at 2*i+1
and 2*i+2.
Args:
arr (list): List of numbers to check.
Returns:
bool: True if the array is a min heap, False otherwise.
"""
n = len(arr)
# Loop over all internal nodes (nodes that have at least one child)
for i in range(n // 2):
left = 2 * i + 1
right = 2 * i + 2
# Check left child
if left < n and arr[i] > arr[left]:
return False
# Check right child
if right < n and arr[i] > arr[right]:
return False
return True
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试