diff --git a/algorithmica/src/sort/heap_sort.rs b/algorithmica/src/sort/heap_sort.rs index f7a0483..6433a85 100644 --- a/algorithmica/src/sort/heap_sort.rs +++ b/algorithmica/src/sort/heap_sort.rs @@ -39,7 +39,7 @@ pub fn sink bool>(arr: &mut [T], k: usize, n: usize, p: let mut k = k; while 2 * k < n { let mut j = 2 * k + 1; - if j < n && p(&arr[j], &arr[j + 1]) { + if j + 1 < n && p(&arr[j], &arr[j + 1]) { j += 1; } if !p(&arr[j], &arr[k]) {