4. Bubble Sort #
Created Wednesday 11 December 2019
**Name: **The largest one sinks at the bottom. Again, the process starts from the very top. // arr - input array // n - size of array
void BubbleSort(int arr[], int n){
// Write your code here
int temp = 0;
for(int i=0; i<n-1; i++) // check n-1 elements
{
for(int j=0; j<n-1-i; j++)
{ // check 0 to last element, which changes at each stage
if(arr[j] > arr[j+1])
{
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
}