311

470

300

98

198

145

431

171

590

944

863

949

Bubble Sort

Bubble sort is a simple sorting algorithm that works by repeatedly swapping adjacent elements in an array that are in the wrong order. This process is repeated until the entire array is sorted. The algorithm starts at the beginning of the array and moves through it, swapping adjacent elements that are out of order. This process is repeated until the end of the array is reached, at which point the algorithm starts again from the beginning. The algorithm continues to iterate through the array and swap adjacent elements until no more swaps are needed. Although bubble sort has a time complexity of O(n^2), which makes it less efficient than other sorting algorithms, it can be useful for small arrays or as a simple illustration of how sorting algorithms work.

AlgorithmTime ComplexitySpace Complexity
BestAverageWorstWorst
Bubble SortO(n)O(n^2)O(n^2)O(1)
Insertion SortO(n)O(n^2)O(n^2)O(1)
Selection SortO(n^2)O(n^2)O(n^2)O(1)
Merge SortO(n log(n))O(n log(n))O(n log(n))O(n)
Quick SortO(n log(n))O(n log(n))O(n^2)O(log (n))
Radix SortO(nk)O(nk)O(nk)O(n+k)
Team Members:
  • Antriksh Katna (22BCS017)