This lesson covers two foundational sorting algorithms: bubble sort and insertion sort.
There are three components to this lesson:
- myGA module: Basic Sorting Algorithms
- In-Class Exercise: Implementing Bubble Sort
- In-Class Exercise: Implementing Insertion Sort
Note: The myGA module contains a link to an exercise in CodePen. The code in CodePen is the exact same as the code for the in-class exercises. Try out the exercise in CodePen and see how far you can get with it. Leave off where you get stuck and we'll review the solution in class.
By the end of this lesson, you will be able to:
- Describe the time and space complexities of bubble sort and insertion sort.
- Implement bubble sort and insertion sort.
- Big O Notation
- Introduction to Sorting
Roughly 2.5 hours total:
- 0.5 hour myGA
- 2 hours in class
- Visualize bubble sort and insertion sort using this fun tool.
- More visuals here: bubble sort, insertion sort.
- Some sample interview questions about bubble sort. (Note: The code in this article is not JavaScript.)
- Recap of how insertion sort works.
- Last but certainly not least: Folk dancing for bubble sort and insertion sort.