Code that defines a custom list class (linked lists) and implements and time sorting algorithms on it
List of nodes
python-lists-in-python/main.py
Lines 7 to 9 in 56f69ac
Nodes have a number in them and point to another node
python-lists-in-python/main.py
Lines 15 to 18 in 56f69ac
Bubble | Selection | Insertion | Merge | Quick | |
---|---|---|---|---|---|
Time Complexity | O(n2) | O(n2) | O(n2) | O(n log n) | O(n log n) |
Compares pairs of elements and swaps them if they are out of order
Takes the smallest element of the main list and adds it to a sub-list until
Takes one element and puts it in its spot
Splits the list into elements then merges pairs of sub-lists keeping the elements in order until is one list again
Selects a pivot and moves all smaller elements to one side it then does the same to each side of the list