public static T[] HeapSort <T>(T[] A) where T : IComparable <T> { BinaryHeap <T> heap = new BinaryHeap <T>(A); Console.WriteLine(); T[] sorted = new T[heap.Count]; int i = 0; while (heap.Count != 0) { sorted[i++] = heap.Remove(); } return(sorted); }
public static int[] HeapSort(int[] A) { BinaryHeap <int> heap = new BinaryHeap <int>(A, HeapType.Max); Console.WriteLine(heap.Contains(8)); Console.WriteLine(); int[] sorted = new int[heap.Count]; int i = 0; while (heap.Count != 0) { sorted[i++] = heap.Remove(); } return(sorted); }