diff options
Diffstat (limited to 'progs/a150.py')
-rw-r--r-- | progs/a150.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/progs/a150.py b/progs/a150.py new file mode 100644 index 0000000..de203fb --- /dev/null +++ b/progs/a150.py @@ -0,0 +1,7 @@ +def check_min_heap(arr, i):
+ if 2 * i + 2 > len(arr):
+ return True
+ left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1)
+ right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2]
+ and check_min_heap(arr, 2 * i + 2))
+ return left_child and right_child
\ No newline at end of file |