Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.74 KB

readme.md

File metadata and controls

45 lines (33 loc) · 1.74 KB

sorting-algorithm-tester

Program Description

This C program allows the user to run a selected sorting algorithm to order the contents of a selected file and show the time elapsed for the operation. The algorithms to choose from are bubble sort, quick sort, and merge sort. The contents for the provided test files were found freely available online and modified to be nearly sorted. The program also allows for the creation of new test files by collecting user input or randomizing existing test files. The series of screenshots below show the difference in performance when sorting operations are performed on nearly sorted file contents and randomly ordered file contents.

The following picture shows the results of quick sort on a nearly sorted file of +58000 lines.

Quick Sort

Figure1. Quick Sort Nearly Sorted

The same file sorted by merge sort results in a shorter run time.

Merge Sort

Figure 2. Merge Sort Nearly Sorted

The nearly sorted file is randomized to create a new test file.

New File

Figure 3. Test File Creation

On the randomly ordered file, quick sort performs much faster.

Quick Sort Random

Figure 4. Quick Sort Random

Merge sort performs more slowly than quick sort on the fully randomized contents.

Merge Sort Random

Figure 5. Merge Sort Random