mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-21 21:11:57 +03: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