public static void Main()
int[] nums = new int[] { 87, 16, 69 , 49, 70, 1, 3 ,4, 5 ,95};
Console.WriteLine("Hello World");
public static void HeapSort(int[] n)
for(int i = length/2 -1; i > 0 - 1; i--)
for (int i=length-1; i>=0; i--)
private static void Heapify(int[] n, int endIndex, int currentIndex)
int largest = currentIndex;
int l = 2*currentIndex + 1;
int r = 2*currentIndex + 2;
if (l < endIndex && n[l] > n[largest])
if (r < endIndex && n[r] > n[largest])
if (largest != currentIndex)
Swap(n, currentIndex, largest);
Heapify(n, endIndex, largest);
public static void Swap(int[] nums, int leftItemIndex, int rightItemIndex)
int tempInnerValue = nums[leftItemIndex];
nums[leftItemIndex] = nums[rightItemIndex];
nums[rightItemIndex] = tempInnerValue;
private static void Print(int[] nums)
Console.WriteLine(string.Join(", ", nums));