Bubble sort is the traditional starting point for studying sorting algorithms. The idea is simple: repeatedly walk through the list, compare each pair of adjacent elements, and swap them when they are out of order. Larger values "bubble" toward the end of the array with each pass, and after enough passes the data is sorted. Because the logic is short and visual, bubble sort is an ideal place to build the habits you will need for harder algorithms: tracing nested loops, counting comparisons and swaps, and reasoning about what is guaranteed after each pass.
In this course, bubble sort serves as the baseline against which insertion sort, merge sort, and quicksort are measured. Its nested-loop structure gives O(n^2) comparisons in the average and worst cases, and an early-exit optimization (stop when a full pass produces no swaps) brings the best case down to O(n) on already-sorted input. It sorts in place with O(1) extra space and, when implemented with a strict greater-than comparison, it is stable — properties you will reuse when you compare algorithms later in the module.
The videos below use C++ and Java for their code walkthroughs, so as you watch, focus on the structure rather than the syntax: where the outer loop ends, why the inner loop shrinks on each pass, and where the swap happens. Then rewrite the same logic in JavaScript using a temporary variable or array destructuring for the swap. Pay particular attention to the "swapped" flag in the optimized version and to the honest discussion of when bubble sort is a reasonable choice (tiny or nearly sorted datasets, teaching, quick prototypes) and when it clearly is not (anything large).
A beginner-oriented lecture from the DSAOne course that explains how bubble sort works step by step before moving into a full code implementation in C++ and Java. Expect a walkthrough of the pass-by-pass behavior of the algorithm, the nested loop structure, and a discussion of its time complexity.
At roughly fourteen minutes it is the most thorough of the three, covering the "what it is," "step-by-step logic," and "time complexity" subtopics in one place, and the pacing is aimed squarely at students meeting the algorithm for the first time.
Geekific opens its sorting algorithms series by explaining bubble sort with worked examples and then implementing it in Java. The video pairs a visual trace of the swapping process with the corresponding code, and the channel maintains a public GitHub repository where the implementation can be read alongside the explanation.
It gives you a second, independently produced explanation of the same algorithm, which is useful for confirming your understanding, and its example-then-code structure makes it easy to translate the logic into JavaScript yourself.
A short, focused video on the optimized form of bubble sort, in which a flag tracks whether any swap occurred during a pass so the algorithm can terminate early. It is likely to show how this small change affects the behavior of the algorithm on already-sorted or nearly sorted input.
This is the piece most introductory treatments gloss over, and it is exactly what separates the O(n) best case from the O(n^2) worst case — essential for the complexity analysis and for judging the algorithm's practical use cases.
Together these videos give you the loop structure and swap mechanics you need to write bubble sort yourself in JavaScript (MO1), while the complexity discussions in the first video and the early-exit optimization in the third let you distinguish best-case O(n) from average- and worst-case O(n^2) behavior with O(1) extra space (MO2). Seeing the in-place swapping of adjacent elements makes bubble sort's stability and in-place properties concrete, giving you a reference point for comparing it against insertion, merge, and quicksort (MO3). Finally, the attention these videos pay to when bubble sort performs acceptably versus when it breaks down on large inputs supports the judgment you will need when selecting an algorithm for a given scenario (MO4).
These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.