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:
Navid Salehi 2021-12-02 22:25:40 +03:30 committed by GitHub
parent c8eec2fb57
commit 934f55f179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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);
}