SORTING
When One said that Something is better than other, There must be at least one parameter to be in consideration for comparison of things. Every comparison involved one or more parameters. Two things are equal and One has to choose only one then another parameter involved to dismiss similarities. With the comparing number of things, we select best according to requirements and priority. These process also gives us Second best, third best up to Nth best OR we say Worst in given things. This series called sorted order from best to worst. We can also generate sorted list for worst to best. I like to explain these Comparisons and sorting
with the example of BUYING SMART PHONE.
with the example of BUYING SMART PHONE.

The way of Sorting any items are different. These can be done with different algorithms. Bubble sort is one of sorting algorithm used in Computer Science.
Bubble Sort
Bubble sorting involves bubbling up to the extreme element each time until given elements obtain its correct position according to the Sorted list of the element. Bubble Sort is also known as Sinking Sort.
Former Mobile Buying Example , If we find the mobile model which is we don’t want to buy and remove it from list until only one mobile model left in list. Then this called Bubble Sort algorithm. Sorting of Integers in Ascending Order By Bubble Sort in C/C++ .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Bubble Sort Function | |
Time Complexity : O(N^2) | |
Space Complexity : O(1) | |
*/ | |
//This Function Sort array of Integers in Ascending Order | |
void Bubble_Sort(int data_array[],int SizeOf_data_array) | |
{ | |
int tmp; | |
for(int i=0;i<SizeOf_data_array;i++) | |
for(int j=0;j<SizeOf_data_array-1;j++) | |
if(data_array[i]>data_array[j]) | |
{ | |
tmp=data_array[i]; | |
data_array[i]=data_array[j]; | |
data_array[j]=tmp; | |
} | |
} |
Comments
Post a Comment