Bubble sort in C

In this post, let’s see how to implement bubble sort in C.

Bubble sort, also known as sinking sort,compares adjacent elements and swap them if they are not in correct order.
Here is a simple illustration of bubble sort.
Bubble sort
Above GIF is generated from algorithms app.

Output:

Array before sorting: 67 23 45 74 12 34
Array after sorting: 12 23 34 45 67 74

Both worst case and average case complexity is O (n^2) for bubble sort.

Join Our News Letter – Stay Updated

Subscribe to Awesome Java Content.




Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog