Bubble Sort Algorithm C Descending Order
To arrange an array in ascending order two neighboring elements are compared.
Bubble sort algorithm c descending order. Bubble sort compares each pair of adjacent items and swaps them if they are in the wrong order. Submitted by raunak goswami on august 09 2018. Bubble sort is comparison based sorting algorithm. If one element is larger then the other than the two elements are exchanged.
In this article we are going to learn about bubble sort its algorithm flow chart and c program to implement bubble sort. Since algorithm are language independent so you can use this algorithm to write your code in any language that you prefer. This sorting algorithm is also known as sinking sort. Starting from the first index compare the first and the second elements if the first element is greater than the second element they are swapped.
The bubbles sort method is used to arrange values of an array in ascending or in descending order. We are going to look at the algorithm of one of the simplest and the easiest sorting technique. This algorithm is not suitable for large number of data set. Bubble sort is a sorting technique to sort an array or we can say to sort a list of many numbers.
Bubble sort is a simple sorting algorithm. Although this is the simplest method to sort the list of numbers it is not the best way. Bubble sort is an algorithm that compares the adjacent elements and swaps their positions if they are not in the intended order. Following program is implementing bubble sort algorithm for sorting the numbers in ascending order.
How bubble sort works. In this algorithm adjacent elements are compared and swapped to make correct sequence. It sorts the elements if they are in wrong order. Through the exchange of elements the larger value slowly floats or bubbles up to the top.