Skip to content

Instantly share code, notes, and snippets.

@ox1111
ox1111 / Sort.java
Last active June 22, 2020 06:32 — forked from pulkitnehra/Sort.java
Working of Heap sort
static void sort(int arr[])
{
// to sort the elements
int n = arr.length;
// build max heap
for(int i = n/2 - 1 ;i>=0; i--)
{
// i=n/2-1 as it will give us the left and right child nodes at the first level of the heap
heapify(arr,n,i);
}