fixing the comments
This commit is contained in:
committed by
JamesFlare1212
parent
83e54834d8
commit
2fa18a094f
@@ -142,8 +142,8 @@ void heapify(std::vector<int>& nums, int n, int i){
|
|||||||
smallest = right;
|
smallest = right;
|
||||||
}
|
}
|
||||||
|
|
||||||
// after the above, smallest basically will either stay the same, or will be either left or right, depending on nums[left] is larger or nums[right] is larger. largest stays the same if it is already larger than its two children.
|
// after the above, smallest basically will either stay the same, or will be either left or right, depending on nums[left] is smaller or nums[right] is smaller. smallest stays the same if it is already smallest than its two children.
|
||||||
// if largest is changed, then we do need to swap.
|
// if smallest is changed, then we do need to swap.
|
||||||
if(smallest != i){
|
if(smallest != i){
|
||||||
std::swap(nums[i], nums[smallest]);
|
std::swap(nums[i], nums[smallest]);
|
||||||
heapify(nums, n, smallest);
|
heapify(nums, n, smallest);
|
||||||
|
|||||||
Reference in New Issue
Block a user