Skip to content

Commit

Permalink
Update smooth_sort.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
kanishkgits committed Oct 7, 2024
1 parent 5e50163 commit 1949559
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sorting/smooth_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ fn heapify_leonardo(nums: &mut [i32], index: usize, sizes: &[usize], mut heaps:
break;
}

let left_child = current.saturating_sub(heap_size);
let right_child = current.saturating_sub(1);
let left_child = if current >= heap_size { current - heap_size } else { break };
let right_child = if current > 0 { current - 1 } else { break };

if nums[current] < nums[left_child] {
nums.swap(current, left_child);
Expand All @@ -71,7 +71,7 @@ fn heapify_leonardo(nums: &mut [i32], index: usize, sizes: &[usize], mut heaps:
}

heaps -= 1;
heap_size = heap_size.saturating_sub(1);
heap_size = sizes[heaps];
}
}

Expand Down

0 comments on commit 1949559

Please sign in to comment.