예제 #1
0
def test_selection(array):
    print("Testing selection sort")
    start = timer()
    selection_sort(0, len(array), array)
    end = timer()
    time = end - start
    if is_sorted(array):
        print("Sort time is: ", time)
    else:
        print("Not sorted")
    return time
예제 #2
0
def test_selection_selection(array):
    print("Testing selection/selection combo")
    start = timer()
    selection_sort(0, len(array)//2, array)
    end = timer()
    first_half = end-start
    start = timer()
    selection_sort(0,len(array), array)
    end = timer()
    second_half = end-start
    time = first_half + second_half
    if is_sorted(array):
        print("Sort time is: ", first_half + second_half)
    else:
        print("Not sorted")
    return time