from __future__ import division

class MaxHeap(object):
    def __init__(self):
        self.array = []

    def parent_index(self, index):
        return int((index-1)/2)

    def children_index_tuple(self, index):
        return (2 * index + 1, 2 * index + 2)

    def swap(self, index1, index2):
        self.array[index1], self.array[index2] =  self.array[index2], self.array[index1]

    def percolate_up(self, index):

        if index == 0:
            return

        parent_index = self.parent_index(index)
        parent = self.array[parent_index]
        current = self.array[index]

        if current <= parent:
            return
        self.swap(index, parent_index)

        self.percolate_up(parent_index)

    def push(self, elem):
        index = len(self.array)
        self.array.append(elem)
        self.percolate_up(index)

    def peek(self):
        if len(self.array) == 0:
            return None
        return self.array[0]

    def populate(self, n):
        for _ in range(n):
            self.push(random.randint(-10*n,10*n))
        return self

@@ -24,16 +24,49 @@
 division
+%0Aimport random%0Aimport numpy as np
 %0A%0Aclass 
@@ -223,16 +223,12 @@
 _ind
-ex_tuple
+ices
 (sel
@@ -253,17 +253,77 @@
  return 
-(
+filter(lambda x: len(self.array) %3E x,%0A                      %5B
 2 * inde
@@ -342,16 +342,17 @@
 ndex + 2
+%5D
 )%0A%0A    d
@@ -800,32 +800,417 @@
 (parent_index)%0A%0A
+    def percolate_down(self, index):%0A        children_indices =  self.children_indices(index)%0A        children = %5Bself.array%5Bchild%5D for child in children_indices%5D%0A        if len(children) == 0 or self.array%5Bindex%5D %3E= max(children):%0A            return%0A        max_index = children_indices%5Bnp.argmax(children)%5D%0A        self.swap(index, max_index)%0A        self.percolate_down(max_index)%0A%0A
     def push(sel
@@ -1394,16 +1394,16 @@
 rn None%0A
-
         
@@ -1424,16 +1424,158 @@
 ray%5B0%5D%0A%0A
+    def pop(self):%0A        value = self.peek()%0A%0A        self.array%5B0%5D = self.array.pop()%0A        self.percolate_down(0)%0A        return value%0A%0A
     def 

Add pop function