mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
fix: fixed index of parent in sorting/heap_sort_2.c (#914)
* fixed index of parent * fixed spacing to pass autochecks * Empty commit to test the CI Co-authored-by: Panquesito7 <halfpacho@gmail.com>
This commit is contained in:
parent
d8804a60ab
commit
f851fbbe2f
@ -81,10 +81,10 @@ void heapifyDown(int8_t *arr, const uint8_t size)
|
||||
*/
|
||||
void heapifyUp(int8_t *arr, uint8_t i)
|
||||
{
|
||||
while (i > 0 && arr[i / 2] < arr[i])
|
||||
while (i > 0 && arr[(i - 1) / 2] < arr[i])
|
||||
{
|
||||
swap(&arr[i / 2], &arr[i]);
|
||||
i /= 2;
|
||||
swap(&arr[(i - 1) / 2], &arr[i]);
|
||||
i = (i - 1) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user