The sorting algorithm visualization is a small demo application to easily compare different sorting algorithms. It is capable of sorting a completely random dataset aswell as a nearly sorted dataset, to show of the differences in runtime.
For example:
Quicksort:
Selectionsort:
Bubblesort (sorting 2 swapped datapoints):
The software is build to easily extend the sorting algorihms:
In order to add a new sorting algorithm, just add a new class to (SortingAlgorithms.py):
class NewSortingAlgorithm(SortingAlgorithm):
def __init__(self, data_set: list, call_on_swap, redraw_step_size: int):
super().__init__(data_set, call_on_swap, redraw_step_size)
def sort(self):
...
super().sorted()
@staticmethod
def name():
return "Name of sorting algorithm"
After that you have to register your new algorithm in the class SortingAlgorithms:
def __init__(self):
self.algorithms = list()
self.algorithms.append(BubbleSort)
self.algorithms.append(QuickSort)
self.algorithms.append(InsertionSort)
self.algorithms.append(SelectionSort)
...
self.algorithms.append(NewSortingAlgorithm) # register new algorithm
That's all!
Enjoy!