Bubble Sort
Last updated
What is Bubble Sort?
Bubble Sort is a simple sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order. It gets its name because with each iteration the largest element "bubbles" up to its proper location. It continues this process of swapping until the entire list is sorted in ascending order. The main steps of the algorithm are: starting from the beginning of the list, compare every pair of adjacent items and swap them if they are in the wrong order, and then pass through the list until no more swaps are needed. However, despite being simple, Bubble Sort is not suited for large datasets as it has a worst-case and average time complexity of O(n²), where n is the number of items being sorted.
Free resources to learn Bubble Sort
- ArticleBubble Sort Visualize
- VideoBubble Sort
- VideoBubble Sort
More in stage 9: Graph Data Structures
Bubble Sort: common questions
Can I learn Bubble Sort in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Bubble Sort in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Bubble Sort tutorial for beginners?
It is lesson 45 of 107 in the free Data Structures & Algorithms roadmap, in stage 9, Graph Data Structures. If you are new to Data Structures & Algorithms, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.