In this practice, you will be implementing an insertion sort based on the pseudocode provided to you.
Clone practice from the starter.
Install all packages by running npm install
Read through all the instructions and specs to understand the task.
Run test specs with npm test
Remember Polya's problem solving framework as you go through these exercises.
- Understand the problem
- Make a plan
- Carry out the plan
- Look back and improve your solution
You will be implementing classic algorithms in code. Review the readings to understand the problem.
You are given the plan in comments already. Study these carefully!
These exercises are meant for you to practice carrying out the plan. Focus on translating the plans to JavaScript code.
If you finish early, you will be able to improve your solutions by refactoring your sorting algorithms to run in-place.
Read through the pseudo-code in the insertion-sort.js file to implement insertion sort.
This exercise makes use of console.log
to make sure that your implementations
of insertion sort is correct. Note each intermediate state of the arrays in
test/sort-specs.js.
If you follow the pseudocode, your console.log
outputs will match the order
in the specs.
Time and plot the performance of your implementations on a Google Sheet.