Your task for this deliverable is to research and implement the Insertion Sort
Algorithm.
- fork and clone this repo
- use
sort.py
for your Insertion sort implementation - run
python3 sort.py
to check your work
Insertion sort is a in place
comparison sort, of the same breed as bubble sort
and selection sort
. Insertion sort has a high time complexity compared to some sorts, but a low space complexity and tends to be faster on large sets. It is suitable for situations where memery is a restricted resource.
This algorithm iterates over a set, assuming the first item in the set is sorted. It then checks each member of the set, and moves them to their proper sorted posisition.
When learning a new algorithm, it is a good idea to do your best to understand it without immediately looking at source code. Why? It helps the learning process by working through the problem yourself.
Always try the following when learning a new algorithm to understand it most effectively:
- research and understand how the algorithm works
- Searching for visualizations of the algorithm can be a BIG HELP
- break the algorithm down into steps, 'rubber ducking' or talking through the algorithm aloud can be a great help
- recreate the algorithmic steps in your physical space, for example use a deck of cards to execute each step of the alhgorithm
- write the alogorithm out using pseudocode, try rubber ducking as you do this
- implement the pseudocode code you wrote and test your code, try to think of edge cases that you need to test and account for
- if something isn't working, loop back to step 1.
- this is hard...take breaks for your mental and physical health!
- All content is licensed under a CC-BY-NC-SA 4.0 license.
- All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].