mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-21 21:11:57 +03:00
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 <halfpacho@gmail.com>
This commit is contained in:
parent
c8eec2fb57
commit
934f55f179
@ -68,7 +68,7 @@ void merge(int *a, int l, int r, int n)
|
||||
}
|
||||
}
|
||||
|
||||
for (c = l; c < r - l + 1; c++) a[c] = b[c];
|
||||
for (c = l; c < r + 1; c++) a[c] = b[c];
|
||||
|
||||
free(b);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user