public HeapSort(int[] array) { Array.ForEach(array, item => HeapObject.Add(item)); }
static void Main(string[] args) { Heap <int> heap = new Heap <int>(4); Console.WriteLine($"Height (0): {heap.Height}"); heap.Add(10); Console.WriteLine($"IsPerfect ({heap.Size}): {heap.IsPerfect}"); Console.WriteLine($"Height (1): {heap.Height}"); heap.Add(40); heap.Add(80); Console.WriteLine($"IsPerfect ({heap.Size}): {heap.IsPerfect}"); Console.WriteLine($"Height (3): {heap.Height}"); heap.Add(30); heap.Add(40); heap.Add(20); heap.Add(41); Console.WriteLine($"IsPerfect ({heap.Size}): {heap.IsPerfect}"); Console.WriteLine($"Height (7): {heap.Height}"); heap.Add(45); Console.WriteLine($"IsPerfect ({heap.Size}): {heap.IsPerfect}"); Console.WriteLine($"Height (8): {heap.Height}"); heap.Add(23); heap.Add(34); heap.Add(47); heap.Add(29); heap.Add(34); heap.Add(29); heap.Add(34); Console.WriteLine($"Height: {heap.Height}"); Console.WriteLine($"Is Complete: {heap.IsComplete}"); //heap.Add(4); //heap.Add(6); //heap.Add(8); //heap.Add(10); //heap.Add(12); //heap.Add(3); //heap.Add(1); //heap.Add(1); //heap.Add(2); //heap.Add(5); Console.WriteLine(heap); Console.WriteLine($"Dequeue: {heap.Remove()}"); Console.WriteLine(heap); Console.WriteLine($"Dequeue: {heap.Remove()}"); Console.WriteLine(heap); //Console.WriteLine($"Dequeue: {heap.Dequeue()}"); //Console.WriteLine(heap); //Console.WriteLine($"Dequeue: {heap.Dequeue()}"); //Console.WriteLine(heap); //Console.WriteLine($"Dequeue: {heap.Dequeue()}"); //Console.WriteLine(heap); //Console.WriteLine($"Dequeue: {heap.Dequeue()}"); //Console.WriteLine(heap); //Console.WriteLine($"Dequeue: {heap.Dequeue()}"); //Console.WriteLine(heap); //Console.WriteLine($"Dequeue: {heap.Dequeue()}"); //Console.WriteLine(heap); //Console.WriteLine($"Dequeue: {heap.Dequeue()}"); //Console.WriteLine(heap); }