Bubble Sort Solution
unknown
c_cpp
2 years ago
335 B
5
Indexable
void bubbleSort(vector<int>& arr, int n)
{
//write your code here
for(int i = n - 1; i >= 0 ; i--){
for(int j = 0; j <= i - 1; j++){
if(arr[j]> arr[j + 1]){
int temp = arr[j+ 1];
arr[j + 1] = arr[j];
arr[j] = temp;
}
}
}
}Editor is loading...
Leave a Comment