Skip to main content
Practice

What is Bubble Sort?

Bubble sort is a straightforward sorting method that involves comparing two adjacent elements and sending the larger one to the back.


Key Features

  • Adjacent Element Comparison: It sequentially compares adjacent elements for sorting.

  • Swap After Comparison: If adjacent elements are not in the desired order, they are swapped.

  • Repetition: The entire array is iterated multiple times for sorting.

  • Poor Time Complexity (O(n²)): Bubble sort is a somewhat inefficient sorting method with a time complexity proportional to the square of the number of elements.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.