From 2079046d467eadb760fb3adb063b0a9960780779 Mon Sep 17 00:00:00 2001 From: kevinnls <57634663+kevinnls@users.noreply.github.com> Date: Mon, 20 Sep 2021 10:34:26 +0530 Subject: [PATCH] fix: stop swapping over bounds --- bubblesort/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bubblesort/main.c b/bubblesort/main.c index 299aa40..cb60607 100644 --- a/bubblesort/main.c +++ b/bubblesort/main.c @@ -35,7 +35,7 @@ int* sort(int* arr, int length){ int changes = 0; do { changes = 0; - for(int i=1; iarr[i+1]){ if(DEBUG)printf("need to swap [%d]->%d and [%d]->%d\n",i,arr[i],i+1,arr[i+1]); swap(arr, i, i+1);