def start_algorithm(): """ Starts the algorithm based on the selection from the user in the ComboBox Expected Complexity: dependent on the sort selected """ global data_list if algorithm_menu.get() == "Bubble Sort": bubble_sort(data_list, draw_data, speed_scale.get()) elif algorithm_menu.get() == "Selection Sort": selection_sort(data_list, draw_data, speed_scale.get()) elif algorithm_menu.get() == "Insertion Sort": insertion_sort(data_list, draw_data, speed_scale.get()) elif algorithm_menu.get() == "Quick Sort": quick_sort(data_list, 0, len(data_list) - 1, draw_data, speed_scale.get()) elif algorithm_menu.get() == "Merge Sort": merge_sort(data_list, 0, len(data_list) - 1, draw_data, speed_scale.get()) elif algorithm_menu.get() == "Heap Sort": heap_sort(data_list, draw_data, speed_scale.get()) elif algorithm_menu.get() == "Cocktail Sort": cocktail_sort(data_list, draw_data, speed_scale.get())
def test_bubble_sort(self): for x in range(TEST_ARRAYS_COUNT): array = [random.randrange(0, 1000) for y in range(x * 100 + 1)] unsorted = array.copy() unsorted.sort() bubble_sort(array) self.assertEqual(unsorted, array)
def StartAlogrithm(): global data if not data: return if algMenu.get() == 'Quick Sort': quick_sort(data, 0, len(data) - 1, drawData, speedScale.get()) drawData(data, ['green' for x in range(len(data))]) elif algMenu.get() == 'Bubble Sort': bubble_sort(data, drawData, speedScale.get())
def StartAlgorithm(): global data if not data: return if algo_menu.get() == "Bubble Sort": bubble_sort(data, drawData, speedScale.get()) elif algo_menu.get() == "Merge Sort": merge_sort(data, drawData, speedScale.get()) drawData(data, ["skyblue" for x in range(len(data))])
def start_algo(): global data if not data: return if algo_menu.get() == 'Quick Sort': quick_sort(data, 0, len(data) - 1, draw_data, speed_scale.get()) elif algo_menu.get() == 'Bubble Sort': bubble_sort(data, draw_data, speed_scale.get()) elif algo_menu.get() == 'Merge Sort': merge_sort(data, draw_data, speed_scale.get()) draw_data(data, ['purple' for i in range(len(data))])
def test_bubble(user_int): test_list = [i for i in range(user_int)] random.shuffle(test_list) start_time = time.time() bubble_sort(test_list) final_time = time.time() total_time = final_time - start_time result_str = generate_results(test_list, total_time, " Bubble") print(result_str) return None
def test_bubble(user_int): # build the test list test_list = [i for i in range(user_int)] random.shuffle(test_list) # time tracking of the sort start_time = time.time() bubble_sort(test_list) final_time = time.time() # generate and print results total_time = final_time - start_time result_str = generate_results(test_list, total_time, " Bubble") print(result_str) return None
def start_algorithm(): global data selected_algo = algo_list.get("anchor") # print("Selected Algorithm "+selectedAlgo) # print(data) # bubble_sort(data, draw_data, speed_scale.get()) if not data: return if selected_algo == 'Bubble Sort': bubble_sort(data, draw_data, speed_scale.get()) # elif selected_algo == 'Quick Sort': # quick_sort(data, 0, len(data)-1, drawData, speedScale.get()) # drawData(data, ['green' for x in range(len(data))]) # elif selected_algo == 'Merge Sort': merge_sort(data, draw_data, speed_scale.get())
def StartAlgorithm(): global data if not data: return if algMenu.get() == 'Quick Sort': quick_sort(data, 0, len(data)-1, drawData, speedScale.get()) drawData(data, ['green' for x in range(len(data))]) elif algMenu.get() == 'Bubble Sort': bubble_sort(data, drawData, speedScale.get()) elif algMenu.get() == 'Selection Sort': selectionSort(data, drawData, speedScale.get()) elif algMenu.get() == 'Insertion Sort': insertionSort(data, drawData, speedScale.get()) elif algMenu.get() == 'Merge Sort': merge_sort(data, drawData, speedScale.get()) drawData(data, ['green' for x in range(len(data))])
def test_BubbleSort(self): sorted = bubble_sort(self.data_1) self.assertEqual(self.data_1[0], 1) self.assertEqual(self.data_1[1], 2) self.assertEqual(self.data_1[2], 3) self.assertEqual(self.data_1[3], 4) self.assertEqual(self.data_1[4], 5) self.assertEqual(self.data_1[5], 6) self.assertEqual(self.data_1[6], 7) self.assertEqual(self.data_1[7], 8) self.assertEqual(self.data_1[8], 9) self.assertEqual(self.data_1[9], 10)
def StartAlgorithm(): global data bubble_sort(data, drawData, speedScale.get())
def test1(self): arr = [1, 2, 3, 4, 5, 6, 7] assert bubble_sort(arr) == [1, 2, 3, 4, 5, 6, 7]
def test3(self): arr = [5, 4, 1, 6, 8, 10, 2, 4, 7] assert bubble_sort(arr) == [1, 2, 4, 4, 5, 6, 7, 8, 10]
def test2(self): arr = [1, 2, 3, 4, 5, 6, 7] arr.reverse() assert bubble_sort(arr) == [1, 2, 3, 4, 5, 6, 7]
def start_algorithm(): global data selectedAlgo = algo_list.get("anchor") print("Selected Algorithm " + selectedAlgo) print(data) bubble_sort(data, draw_data, speed_scale.get())
break elif alg == 2: comeco = time.time() merge_sort(numeros, 0, len(numeros) - 1) fim = time.time() - comeco alg = 'Merge-Sort' break elif alg == 3: comeco = time.time() selection_sort(numeros) fim = time.time() - comeco alg = 'Selection-Sort' break elif alg == 4: comeco = time.time() bubble_sort(numeros) fim = time.time() - comeco alg = 'Bubble-Sort' break elif alg == 5: comeco = time.time() shell_sort(numeros) fim = time.time() - comeco alg = 'Shell-Sort' elif alg == 6: comeco = time.time() cocktail_sort(numeros) fim = time.time() - comeco alg = 'Cocktail-Sort' break else: