We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5dc6d19 + a79323e commit c5e4e2eCopy full SHA for c5e4e2e
algorithms/Bubble_Sort.cpp
@@ -1,5 +1,5 @@
1
// O(n^2)
2
-for(int i = 0; i < n; ++i)
+for(int i = 0; i < n - 1; ++i)
3
for(int j = 0, m = n - i - 1; j < m; ++j)
4
if(arr[j] > arr[j + 1])
5
swap(arr[j], arr[j + 1]);
0 commit comments