class HeapArray:
def __init__(self):
self._data = []
self._size = 0
def __str__(self):
return ' '.join([str(i) for i in self._data]) + " Size = "+str(self._size) #try to understand what??
def is_empty(self):
return self._size == 0
def insert(self,e):
self._data.append(e)
# Now we need to adjust
index = self._size
while index > 0 and self._data[index] < self._data[(index-1)//2]:
temp = self._data[index]
self._data[index] = self._data[(index-1)//2]
self._data[(index-1)//2] = temp
index = (index - 1)//2
self._size = self._size + 1
return True
def delete_min(self):
??? next time