def testHeap(self): result = copy(self.original) before = time.time() heapsort(result) after = time.time() print("Heap Sort, size: %d time: %f" % (self.list_length, after-before)) self.assertEqual(self.sorted_list, result, "Heap Sort Failed")
# print random_list2 == random_list1 # Bubble Sort # random_list3 = copy(original) # before = time.time() # bubble_sort(random_list3) # after = time.time() # print random_list3 # print("Bubble Sort, size: %d time: %f" % (list_length, after-before)) # print random_list3 == random_list1 # Quick Sort random_list4 = copy(original) before = time.time() quick_sort(random_list4) after = time.time() #print random_list4 print("Quick Sort, size: %d time: %f" % (list_length, after-before)) print random_list4 == sorted_list # Heap Sort random_list5 = copy(original) #unsorted = [5, 13, 2, 25, 7, 17, 20, 8, 4] #random_list5 = copy(unsorted) before = time.time() heapsort(random_list5) after = time.time() #print unsorted #print random_list5 print("Heap Sort, size: %d time: %f" % (list_length, after-before)) print random_list5 == sorted_list