diff --git a/src/modals/InfoModals.js b/src/modals/InfoModals.js
index cef6e74..992e4d2 100644
--- a/src/modals/InfoModals.js
+++ b/src/modals/InfoModals.js
@@ -80,7 +80,7 @@ const Modals = {
The best case is when we have a sorted array (terminates if no swaps are made)
The worst case is when we have a reverse sorted array (we perform
- n + (n - 1) + (n - 2) + ... = n² comparisons)
+ (n - 1) + (n - 2) + ... + 1 = n(n - 1) / 2 = O(n²)
),
diff --git a/src/pseudocode.json b/src/pseudocode.json
index f8ccfae..cea6e7a 100644
--- a/src/pseudocode.json
+++ b/src/pseudocode.json
@@ -1433,11 +1433,11 @@
"find": {
"code": [
["procedure BubbleSort(array):"],
- [" end ← array.length"],
+ [" end ← array.length - 1"],
[" start ← 0"],
[" while start < end:"],
[" swapped ← start"],
- [" for j ← 0, end:"],
+ [" for j ← start, end - 1:"],
[" if array[j] > array[j + 1]:"],
[" swap array[j], array[j + 1]"],
[" swapped ← j"],
@@ -1453,7 +1453,7 @@
[" start points to first element"],
[" while (start < end):"],
[" lastSwapped points to start"],
- [" for (j from start to end):"],
+ [" for (j from start to end - 1):"],
[" if (array[j] > array[j + 1]):"],
[" bubble array[j] by swapping up"],
[" lastSwapped points to j"],
diff --git a/src/time_complexities.json b/src/time_complexities.json
index f172863..04e9a0f 100644
--- a/src/time_complexities.json
+++ b/src/time_complexities.json
@@ -1032,7 +1032,7 @@
"BubbleSort without Last Swap Optimization": {
"worst": {
"big_o": "O(n²)",
- "explanation": "We compare every element to every other element, which is approximately $n$ times $n$ work.",
+ "explanation": "BubbleSort repeatedly compares adjacent elements, resulting in O(n²) time complexity.",
"example": "[5, 4, 3, 2, 1]"
},
"average": {