mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
Update heap_sort.c
This commit is contained in:
parent
60a69ecf58
commit
ec8d670aea
@ -8,7 +8,9 @@
|
|||||||
void max_heapify(int *a, int i, int n);
|
void max_heapify(int *a, int i, int n);
|
||||||
void heapsort(int *a, int n);
|
void heapsort(int *a, int n);
|
||||||
void build_maxheap(int *a, int n);
|
void build_maxheap(int *a, int n);
|
||||||
|
/**
|
||||||
|
* max_heapify takes O(logn).
|
||||||
|
*/
|
||||||
void max_heapify(int *a, int i, int n)
|
void max_heapify(int *a, int i, int n)
|
||||||
{
|
{
|
||||||
int j, temp;
|
int j, temp;
|
||||||
@ -43,7 +45,9 @@ void heapsort(int *a, int n)
|
|||||||
max_heapify(a, 1, i - 1);
|
max_heapify(a, 1, i - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* build_maxheap takes O(n).
|
||||||
|
*/
|
||||||
void build_maxheap(int *a, int n)
|
void build_maxheap(int *a, int n)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
Loading…
Reference in New Issue
Block a user