Skip to content

Commit 934f55f

Browse files
havijsPanquesito7
andauthored
fix: merge sort bug (#921)
Merge sort does not work properly. To reproduce the bug input 6, 5, 4, 3, 2, 1 the output would be 2, 3, 1, 4, 5, 6. Co-authored-by: David Leal <[email protected]>
1 parent c8eec2f commit 934f55f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sorting/merge_sort.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void merge(int *a, int l, int r, int n)
6868
}
6969
}
7070

71-
for (c = l; c < r - l + 1; c++) a[c] = b[c];
71+
for (c = l; c < r + 1; c++) a[c] = b[c];
7272

7373
free(b);
7474
}

0 commit comments

Comments
 (0)