Ejemplo n.º 1
0
#func to print sorting result
def print_answer(algo_name, work_time, compare_num, exchange_num, sorted_list):
    print(
        str(algo_name) + "\nWORK TIME: " + str(work_time) +
        "\nCOMPARISON NUMBER: " + str(compare_num) + "\nEXCHANGE NUMBER: " +
        str(exchange_num) + "\nSORT RESULT: \n" + str(sorted_list))


#main method
if __name__ == "__main__":

    printer_list = read_data_from_file()
    start = datetime.now().microsecond
    select_sorted_list = selection_sort(printer_list)
    finish = datetime.now().microsecond
    print_answer("SELECTION SORT", work_time(start, finish),
                 Counter.compare_num, Counter.exchange_num, select_sorted_list)
    print(
        "\n\n-------------------------------------------------------------------------------------------\n\n"
    )
    Counter.count_reset()
    quicksort = Quicksort(printer_list)
    start = datetime.now().microsecond
    quicksort.quick_sort(0, len(printer_list) - 1)
    finish = datetime.now().microsecond
    print_answer("QUICKSRT", work_time(start, finish), Counter.compare_num,
                 Counter.exchange_num, quicksort.sort_list)
    print(
        "\n\n-------------------------------------------------------------------------------------------\n\n"
    )