MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / heapSort

Function heapSort

CPP/sorting/heap_sort.cpp:27–42  ·  view source on GitHub ↗

Function to implement the heap sort*/

Source from the content-addressed store, hash-verified

25}
26/*Function to implement the heap sort*/
27void heapSort(int a[], int n)
28{
29
30 for (int i = n / 2 - 1; i >= 0; i--)
31 heapify(a, n, i);
32 // One by one extract an element from heap
33 for (int i = n - 1; i >= 0; i--) {
34 /* Move current root element to end*/
35 // swap a[0] with a[i]
36 int temp = a[0];
37 a[0] = a[i];
38 a[i] = temp;
39
40 heapify(a, i, 0);
41 }
42}
43/* function to print the array elements */
44void printArr(int a[], int n)
45{

Callers 1

mainFunction · 0.70

Calls 1

heapifyFunction · 0.70

Tested by

no test coverage detected