Bottom Up Or Not At All

def sift_down(a, i, n):
    while True:
        smallest, l, r = i, 2 * i + 1, 2 * i + 2
        if l < n and a[l] < a[smallest]: smallest = l
        if r < n and a[r] < a[smallest]: smallest = r
        if smallest == i: return
        a[i], a[smallest] = a[smallest], a[i]
        i = smallest

def heapify(a):
    n = len(a)
    for i in range(n // 2 - 1, -1, -1):
        sift_down(a, i, n)

What is a after heapify(a) when a = [5, 3, 8, 1, 9, 2, 7]?

A

[1, 3, 2, 9, 5, 8, 7]

B

[1, 3, 2, 5, 9, 8, 7]

C

[3, 1, 2, 5, 9, 8, 7]

D

[1, 2, 3, 5, 7, 8, 9]