A collection of sorting algorithms written in Python. An educational tool used for demonstrations of said algorithms.
- Bubble Sort
- Selection Sort
- Selection Sort (Recursion)
- Quick Sort
- Insertion Sort
- Shell sort
- Comb Sort
- Clone Repository:
git clone https://github.com/ArcherHume/sortingAlgorithms.git cd sortingAlgorithms
- Install Dependencies:
pip install -r requirements.txt
- Run Script: Usage
USAGE:
python main.py -t [algorithm]
Flags:
-t [algorithm] (Required): The algorithm you would like to run.
Choose from: selection, selection_recursive, bubble, quick_sort, insertion, shell, comb.
-l [length] (Optional): The length of the array to be sorted. Defaults to 5000.
-r [repeats] (Optional): The number of times to repeat the algorithm. Defaults to 3.
-d [delay] (Optional): The delay between each step of the algorithm, used to watch each individual step. Defaults to 0.
-width [width] (Optional): The width of the screen. Defaults to 800.
-height [height] (Optional): The height of the screen. Defaults to 600.
-h (Optional): Prints this message.
-debug (Optional): Enables debug mode.
Example: python main.py -t selection -l 10000 -r 6
- Open the
modules/sorting_algorithms.py
file. - Create a function with a lowercase, underscore-separated name. Add the positional arguments
array
thendelay
.- Example:
def selection_sort(sorting_array, delay)
- Example:
- Any modifications/sorting done on the array will be reflected on screen.