CJCoding With Joseph
15free / daySign inCreate account

Min Heap Property Check

A min-heap stored in a list has every parent no larger than its children, where the children of index i sit at 2 * i + 1 and 2 * i + 2. Write is_min_heap(values: list[int]) -> bool that returns True when the list satisfies that rule and False otherwise: loop over every index, compute the two child indexes, and whenever a child index is inside the list (below len(values)) and the child's value is smaller than the parent's, the answer is False. Equal values are allowed, and an empty list is a valid heap. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one line of space-separated integers (possibly empty); the tests print the boolean your function returns.

Expected Output:

True

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Data Structures & Algorithms
📥 Auto-Input:
1 3 2 7 4 5\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.