Sorting

Bubble Sort

Bubble Sort

Ashish Lahoti

Why it is called bubble sort ?

Bubble Sort is nothing but a comparison algorithm where -

  • At the end of first iteration, largest element in the array get placed at last index
  • At the end of second iteration, second largest element in the array get placed at second last index and so on…

This way large elements are moving towards the last indexes and hence small elements are moving towards the starting indexes which is also termed as smaller elements “bubble” to the top of the list that is why it is called bubble sort.