Check out a free preview of the full A Practical Guide to Algorithms with JavaScript course:
The "Bubble Sort & Merge Sort Exercise" Lesson is part of the full, A Practical Guide to Algorithms with JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

In this exercise, students implement bubble sort and merge sort.

Get Free Access Now

Transcript from the "Bubble Sort & Merge Sort Exercise" Lesson

[00:00:00]
>> Bianca Gandolfo: So our first learning exercise is implementing Bubble Sort. Remember, this is the Sort that loops through array, and it bubbles up the highest value each time. And our first task is to implement Bubble Sort. So I'm gonna let you do that. The second task that we have for sorting, is to implement MergeSort.

[00:00:25] We went through the pseudo-code quite a bit. So just a reminder that we're gonna split the array in halves, and we're gonna merge them recursively. And once we hit our base case, which is a sorted list of length one, right? So we're gonna check for that base case with length is, either less than two, or equals equals equals one.

[00:00:45] However you wanna do it is fine. And then, that's the base case, and you're gonna start returning out from your recursion. And you're going to compare the arrays item by item. And you're gonna return that result. So this is the conquer part of the divide and conquer paradigm.