def test_sort_order_ordering(): unsorted_list = s.generate_list(200, min_value=0, max_value=500) sorted_list = s.bubblesort(unsorted_list) i = 0 while i < (len(sorted_list) - 1): assert sorted_list[i] <= sorted_list[i + 1] i += 1
def test_sort_order_limits(): min_bound = 0 max_bound = 999 unsorted_list = s.generate_list(200, min_value=min_bound, max_value=max_bound) sorted_list = s.bubblesort(unsorted_list) assert sorted_list[0] >= min_bound assert sorted_list[-1] <= max_bound
quick_sort.grid(row=0, column=1) merge_sort = Button( root, text="Merge sort", command=lambda: sorting.mergesort(value_arry, rect_arry, 0)) merge_sort.grid(row=0, column=2) insertion_sort = Button(root, text="Insertion sort", command=lambda: sorting.insertionsort()) insertion_sort.grid(row=0, column=3) bubble_sort = Button(root, text="Bubble sort", command=lambda: sorting.bubblesort()) bubble_sort.grid(row=0, column=4) #creates scale setting array_size = Scale(root, from_=10, to=200, orient=HORIZONTAL, length=400) array_size.grid(row=0, column=5) #contains rectangle objects rect_arry = [] #contains length to be sorted value_arry = [] #creates initial array of values for x in range(1, array_size.get() + 1): value_arry.append(x)
def test_bubblesort(): list = generateRandomList() sorting.bubblesort(list) assert (is_sorted(list))
def test_sort_order_length(): unsorted_list = s.generate_list(200, min_value=0, max_value=500) sorted_list = s.bubblesort(unsorted_list) assert len(unsorted_list) == len(sorted_list)
def k_selection(l, k): sorting.bubblesort(l) return l[len(l - k)]