Update heap_sort.c

This commit is contained in:
Shezza221b 2020-10-01 04:27:27 +05:30 committed by GitHub
parent 60a69ecf58
commit ec8d670aea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;