Find the largest among root and children largest = i l = 2 * i
Fantastic news! We've Found the answer you've been seeking!
Question:
Find the largest among root and children
largest = i
l = 2 * i + 1
r = 2 * i + 2
if l < n and arr[i] < arr[l]:
largest = 1
if r < n and arr[largest] < arr[r]:
largest = r
I am getting an error message that says below:
Traceback (most recent call last):
File "", line 10, in
NameError: name 'l' is not defined
This is my code:
def heapify(arr, n, i):
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date: