Skip to content

A simple demo to visualise how different sorting algorithms work

License

Notifications You must be signed in to change notification settings

lucajung/sort-algorithm-visualization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sort-algorithm-visualization

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):

Extensibility

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!

About

A simple demo to visualise how different sorting algorithms work

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages