Exemplo n.º 1
0
def sortData(unsortedList):
    """
    This function will run the sorting algortihms, and track their data.
    Input: unsorted list
    Output: data from the sorting algorithms
    """
    # We will begin with the data from the bubble sort
    bubbleSortData = []
    bubbleSortOptData = []
    selectionSortData = []
    insertionSortData = []

    # The range of testing will begin at zero
    testRange = 0

    for i in range(len(unsortedList) + 1):
        bubbleSortCount = Sorts.bubbleSort(unsortedList[:testRange])
        bubbleSortData.append(bubbleSortCount)

        bubbleSortOptCount = Sorts.bubbleSortOpt(unsortedList[:testRange])
        bubbleSortOptData.append(bubbleSortOptCount)

        selectionSortCount = Sorts.selectionSort(unsortedList[:testRange])
        selectionSortData.append(selectionSortCount)

        insertionSortCount = Sorts.insertionSort(unsortedList[:testRange])
        insertionSortData.append(insertionSortCount)
        testRange += 1

    # Write the sort data to text file
    writeSortDataToText(bubbleSortData, bubbleSortOptData, selectionSortData,
                        insertionSortData)