Bubble Sort Solution
Anonymous
c_cpp
04/07/2024 5:51 AM
448 B
14
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