Beispiel #1
0
def startAlgorithm():
    global data
    if not data: return

    if algMenu.get() == 'Quick Sort':
        quick_sort(data, 0, len(data) - 1, drawData, speedScale.get())

    elif algMenu.get() == 'Bubble Sort':
        bubble_sort(data, drawData, speedScale.get())

    elif algMenu.get() == 'Insertion Sort':
        insertion_sort(data, drawData, speedScale.get())

    elif algMenu.get() == 'Merge Sort':
        merge_sort(data, drawData, speedScale.get())

    elif algMenu.get() == 'Selection Sort':
        selection_sort(data, drawData, speedScale.get())

    elif algMenu.get() == 'Selection Sort':
        selection_sort(data, drawData, speedScale.get())

    elif algMenu.get() == 'Radix Sort':
        radix_sort(data, drawData, speedScale.get())
    drawData(data, ['green' for x in range(len(data))])
Beispiel #2
0
def startAlgorith():
    global data
    #Calling the necessary algorith
    if alg_menu.get() == 'BubbleSort':
        bubble_sort(data, drawData, speedScale.get())

    elif alg_menu.get() == 'InsertionSort':
        insertion_sort(data, drawData, speedScale.get())

    elif alg_menu.get() == 'MergeSort':
        merge_sort(data, drawData, speedScale.get())
Beispiel #3
0
def startAlgorithm():
    global array
    if not array:
        return

    # get the speed of the algorithm visualiser
    sizeNum = sizeEntry.get()
    speed = 10 / (sizeNum * pow(sizeNum, 0.5))

    # visualise an algorithm
    if algoMenu.get() == "Insertionsort":
        insertion_sort(array, drawArray, speed)
    if algoMenu.get() == "Mergesort":
        merge_sort(array, drawArray, speed)
    if algoMenu.get() == "Bubblesort":
        bubble_sort(array, drawArray, speed)
    if algoMenu.get() == "Quicksort":
        quick_sort(array, drawArray, speed)
    if algoMenu.get() == "Heapsort":
        heap_sort(array, drawArray, speed)
if __name__ == "__main__":
    array = []
    for i in range(how_many):
        array.append(randint(lower_integer, upper_integer))
    temp = array[:]
    bubble_sort(temp)
    temp = array[:]
    bucket_sort(temp, how_many // 100)
    temp = array[:]
    comb_sort(temp)
    temp = array[:]
    counting_sort(temp)
    temp = array[:]
    heap_sort(temp)
    temp = array[:]
    insertion_sort(temp)
    temp = array[:]
    shell_sort(temp)
    temp = array[:]
    lsd_radix_sort(temp)
    temp = array[:]
    pigeonhole_sort(temp)
    temp = array[:]
    selection_sort(temp)
    temp = array[:]
    (comparisons, array_accesses, additional_space) = merge_sort(temp)
    print("Merge sort:")
    print("No. comparisons: " + str(comparisons) + ", no. array accesses: " +
          str(array_accesses) + ", no. additional space required: " +
          str(additional_space))
    temp = array[:]
Beispiel #5
0
from selectionSort import selection_sort
from insertionSort import insertion_sort
from bubbleSort import bubble_sort
from binarySearch import binary_search
import random

random_array = [random.randint(1, 100) for _ in range(100)]

print("Selection sort time:")
selection_sort(random_array)

print(binary_search(random_array, 76))

print("Insertion sort time:")
insertion_sort(random_array)

print("Bubble sort time:")
bubble_sort(random_array)