Respond to short response questions in clear, concise sentences directly within this file. Use markdown to ensure that your answers are formatted correctly.
Complete code challenges in exercises.js
.
Use Test Driven Development to guide you. Run npm install
to download dependencies. Run npm test
to run tests locally. Ensure all tests are passing before submitting this problem set.
-
There are four sorting algorithms listed below. For each one, please provide:
- A detailed explanation of how the algorithm works
- The space and time complexity in Big O notation
- Some cases when you might prefer or not prefer this algorithm over others (i.e. "This algorithm performs well if the list is already nearly sorted")
Insertion Sort:
Bubble Sort:
Merge Sort:
Quick Sort:
- In the
exercises.js
file, implement each of the sorting algorithms above without using JavaScript's built-inArray.prototype.sort()
method. Each of the functions has been stubbed out for you, but you are welcome to create your own helper functions if needed.