Bubble Sort Algorithm

SORTING

Sorting is the process of arranging given numbers or elements in ascending or descending order.

Other sorting techniques

  • Insertion sort
  • Quick sort
  • Heap sort
  • Bucket sort
  • Shell sort
  • Radix sort etc.

BUBBLE SORT

Bubble sort is the simple sorting algorithm. It is easy to understand and implement. Bubble sort is called so because elements tend to move up into the correct order like bubbles rising to the surface.

Let N = number of elements in a list. Assume counting starts from 0 (zero), as computer recognises zero as a number.

Bubble sort

Bubble sort example

NOTE: observe that there are no more elements to compare in pass 1. After pass 1, the largest element comes to an end of the list or array. So, last element doesn’t have to be compared in next pass. So pass 2 contains only 3 comparisons as shown below:

Bubble sort example

Gopal Krishna

Hey Engineers, welcome to the award-winning blog,Engineers Tutor. I'm Gopal Krishna. a professional engineer & blogger from Andhra Pradesh, India. Notes and Video Materials for Engineering in Electronics, Communications and Computer Science subjects are added. "A blog to support Electronics, Electrical communication and computer students".

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »