You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for(int j=0;j<=n-2-i;j++){ // last elemenst will keep getting sorted
if(arr[j]>arr[j+1]){
int temp = arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
printArray(arr,n);
}
}
intmain(){
// int arr[] = {3,5,1,7,3,8};
int arr[] = {5,7,3,1,5,6,3,5,1,8,9,3,4,5,6,7,2,3,4,5,2,3,4,8,9,4,5,6,7,4,5,6,3,4,5,6,7,8,9,0,3,4,5,6,3,5,1,7,3,8,4,2,7,6,5,3,1,8,9,0,3,4,5,6,7,8,9,3,4,5,6,7,2,3,4,5,2,3,4,8,9,4,5,6,7,4,5,6,3,4,5,6,7,8,9,0,3,4,5,6};
int n = sizeof(arr)/sizeof(*arr);
cout << " size of input n "<< n << endl;
printArray(arr,n);
auto start = high_resolution_clock::now();
bubblesort(arr, n);
auto stop = high_resolution_clock::now();
cout << "\nSorted array is \n";
printArray(arr, n);
auto duration = duration_cast<microseconds>(stop - start);