Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why bubble sort is called bubble sort?

I am learning bubble sort. And I tend to forget about the type of sort everytime. So I am trying to find the logical meaning of each sort so that it helps in recalling the logic of sort :

I could not understand exact meaning that why bubble sort is named bubble sort?

like image 640
Onki Avatar asked Jun 25 '15 19:06

Onki


People also ask

What is bubble sort also known as?

Bubble sort algorithm, also known as sinking sort, is the simplest sorting algorithm that runs through the list repeatedly, compares adjacent elements, and swaps them if they are out of order.

Why is it called selection sort?

This algorithm is called selection sort because it repeatedly selects the next-smallest element and swaps it into place.

What is bubble sort explain with example?

Bubble sort starts with very first two elements, comparing them to check which one is greater. ( 5 1 4 2 8 ) –> ( 1 5 4 2 8 ), Here, algorithm compares the first two elements, and swaps since 5 > 1. ( 1 5 4 2 8 ) –> ( 1 4 5 2 8 ), Swap since 5 > 4. ( 1 4 5 2 8 ) –> ( 1 4 2 5 8 ), Swap since 5 > 2.

Who invented bubble sort?

The term “Bubble Sort ” was first used by Iverson in 1962 [5]. Invariant: At the end of ith iteration, the last i elements contain i largest elements. i.e. a[n] contains the largest, a[n − 1] contains the second largest, and so on. At the end of nth iteration, the array is sorted as it contains n largest elements.


1 Answers

Why is it called bubble sort?

The bubble sort gets its name because elements tend to move up into the correct order like bubbles rising to the surface.

like image 87
Jean Logeart Avatar answered Oct 28 '22 08:10

Jean Logeart