From 549164eb30bdb9910efa96f9c6e8eaf837fa3623 Mon Sep 17 00:00:00 2001 From: Sammy Nah Date: Wed, 6 Sep 2023 05:28:37 -0700 Subject: [PATCH] Bubble sort code fix --- chapter03.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter03.tex b/chapter03.tex index 00b095d..b081752 100644 --- a/chapter03.tex +++ b/chapter03.tex @@ -86,7 +86,7 @@ \subsubsection{$O(n^2)$ algorithms} The algorithm can be implemented as follows: \begin{lstlisting} for (int i = 0; i < n; i++) { - for (int j = 0; j < n-1; j++) { + for (int j = 0; j < n-i-1; j++) { if (array[j] > array[j+1]) { swap(array[j],array[j+1]); }