class heap:
def __init__(self,the_heap):
self.heap = the_heap
def getChildren(self,value):
n = self.heap.index(value)
return self.heap[2*n+1],self.heap[2*n+2] # i think ...
def getParent(self,value):
n = self.heap.index(value)
if n == 0: return None
return self.heap[math.floor(n-1/2.0) ] # i think ...
def traverse(self):
#do your traversal here just visit each node in the order you want
pass
the_heap = heap(range(100))
print the_heap.getChildren(2)
print the_heap.getParent(6)
something like that?