Bubble Sort Implementation & Demonstration

Bubble Sort (Ascending)

  1. In this algorithm we compare  the first two adjacent items in the  list. If the first item is larger than the item next to it, we swap them, else we do nothing.
  2. This process (step1) is repeated until we have reached the end of the list.  At this point, the largest item is at the end of the list, we say it was “bubbled” up the list.
  3. Repeat step 1 and 2 for items 1 .. n-1, then 1 .. n-2 and so on until we reach 1..2

It seems difficult to understand but we can observe the algorithm in action in the following flowchart:

You can download the file here:



See : https://youtu.be/KgqM6sC5Q4M


Implement the algorithm in c with the following modifications:

  • The array stores double data
  • Print the array to the screen as a comma separated list before sorting.
  • Print the array to the screen as a comma separated list after sorting.


Create a function with the following functions declaration which will sort any double array using bubble sort:

            void bubbleSort(double array[], int sizeOfArray);

© 2020  Vedesh Kungebeharry. All rights reserved.