def heap_peak(name): if name in heapdict.keys(): v = heapdict[name] name = BinHeap_Array() name.heapify(v) return str(name.peek()) else: return "There is no heap with desired name", 400
def heap_get(name=None): if name == None: return "Please enter a name for the heap you want to inquiry!", 400 if name in heapdict.keys(): v = heapdict[name] name = BinHeap_Array() name.heapify(v) return "The size of the heap is " + str(name.size) + '\n' + "The heap is (in array format):" + ','.join(map(str,name._print())) else: return "There is no heap with desired name", 400
def heap_pop(name): if name in heapdict.keys(): tmp = name v = heapdict[name] name = BinHeap_Array() name.heapify(v) out = str(name.remove()) heapdict[tmp] = name._print() return out else: return "There is no heap with desired name", 400
def heap_get(name=None): if name == None: return "Please enter a name for the heap you want to inquiry!", 400 if name in heapdict.keys(): v = heapdict[name] name = BinHeap_Array() name.heapify(v) return "The size of the heap is " + str( name.size) + '\n' + "The heap is (in array format):" + ','.join( map(str, name._print())) else: return "There is no heap with desired name", 400
def Testheapify(self): heap1 = BinHeap_Array() heap1.heapify([9]) self.assertEqual(heap1._print(),[9]) heap1.heapify([5,4,3,2]) self.assertEqual(heap1._print(),[2,3,4,9,5])
def Testheapify(self): heap1 = BinHeap_Array() heap1.heapify([9]) self.assertEqual(heap1._print(), [9]) heap1.heapify([5, 4, 3, 2]) self.assertEqual(heap1._print(), [2, 3, 4, 9, 5])