Snippets Collections
void sortArray (int *arr, int n) {
  if (n==0||n==1)
    return;
  for (int i=0; i<n-1; i++) {
    if (arr[i]>arr[i+1]) {
      swap(arr[i],arr[i+1]);
    }
  }
  sortArray(arr,n-1);
}
void sortArray(int arr[], int n) {
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < (n - i); j++) {
      if (arr[j] > arr[j + 1]) {
        swap(arr[j], arr[j + 1]);
      }
    }
  }
}
star

Mon Jun 24 2024 11:09:55 GMT+0000 (Coordinated Universal Time)

#c++ #dsa #bubblesorting #sorting

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension