private static void Main() { var arr = new[] { 1, 5, 4, 2, 7, 8, 9, 12, 15, 20, 31, 42, 2, 6 }; var floydHeap = FloydMaxHeap.BuildMaxHeap(arr); while (!floydHeap.IsEmpty) { Console.Write(floydHeap.Pop() + " "); } }
public static IEnumerable <int> HeapSortExecute(params int[] collection) { var heap = FloydMaxHeap.BuildMaxHeap(collection); var arr = new int[collection.Length]; while (heap.Count > 0) { var current = heap.Pop(); arr[heap.Count] = current; } return(arr); }