def startalgo(): global data if not data: return timetick=speedScale.get() algo = algMenu.get() if algo == "": response=messagebox.showwarning("Warning","Please select the Algorithm") if algo == "Bubble Sort": bubble(data, drawData, timetick) if algo == "Merge Sort": mergesort(data,drawData,timetick) if algo == "Quick Sort": quick(data,0,len(data)-1,drawData,timetick) drawData(data,["#7CFC00"for x in range(len(data))]) #green
def StartAlgo(): global data sp = float(speed.get()) a = algo.get() if a == 'Merge Sort': mergesort(data, 0, len(data) - 1, Getdata, sp) elif a == 'Quick Sort': quciksort(data, 0, len(data) - 1, Getdata, sp) elif a == 'Bubble Sort': bubbleSort(data, Getdata, sp) elif a == 'Selection Sort': selection(data, Getdata, sp) elif a == 'Insertion Sort': insertion_sort(data, Getdata, sp) Getdata(data, ['blue' for i in range(len(data))])
def test_merge2(self): ret = mergesort([0, 10, 1, 1]) self.assertEqual(ret, [0, 1, 1, 10])
def test_merge1(self): ret = mergesort([8, 5, 1, 2, 4]) self.assertEqual(ret, [1, 2, 4, 5, 8])
print "bubblesort success!" else: print "bubblesort incorrect." except: print "bubblesort function errored or is incomplete." try: from insertion import insertion if (insertion(list(nums)) == sortedNums): print "insertionsort success!" else: print "insertionsort incorrect." except: print "insertionsort function errored or is incomplete." try: from merge import mergesort if (mergesort(list(nums)) == sortedNums): print "mergesort success!" else: print "mergesort incorrect." except: print "mergesort function errored or is incomplete." try: from quick import quick if (quick(list(nums)) == sortedNums): print "quicksort success!" else: print "quicksort incorrect." except: print "quicksort function errored or is incomplete." try:
input_is = input(input_message) # Build and randomly shuffle list of integers. vector = [x + 1 for x in range(number_interation)] random.seed(time.time()) random.shuffle(vector) if input_is == "i": title = "Insertion Sort" generator = insertion_sort(vector) elif input_is == "b": title = "Bucket Sort" generator = bucketsort(vector, bucketSize=DEFAULT_BUCKET_SIZE) elif input_is == "m": title = "Merge Sort" generator = mergesort(vector, 0, number_interation - 1) elif input_is == "s": title = "Shell Sort" generator = shellsort(vector) elif input_is == "q": title = "Quick Sort" generator = quicksort_graph(vector, 0, number_interation - 1) elif input_is == "h": generator = heapsort(vector) title = 'heapsort' elif input_is == "r": generator = radixsort(vector) title = 'radix' # Inicializando grafico fig, ax = plt.subplots()