Question: Find the largest among root and children largest = i l = 2 * i + 1 r = 2 * i
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):
Step by Step Solution
3.41 Rating (145 Votes )
There are 3 Steps involved in it
It appears that youre experiencing a NameError because the variable l is not defined ... View full answer
Get step-by-step solutions from verified subject matter experts
