public static void MaxHeapHelper() { int[] arr = { 4, 5, 1, 6, 7, 3, 2 }; Console.Write("Input Array for the MaxHeap problem : "); ArrayHelpers.PrintIntArray(arr); BinaryHeap maxHeap = new BinaryHeap(); maxHeap.BuildMaxHeap(arr); int?maxValue = maxHeap.Maximum(arr); Console.WriteLine("Maximum value in the heap is : {0}", maxValue); int extractMax = maxHeap.ExtractMaximum(arr); Console.WriteLine("Extract Maximum value in the heap is : {0}", extractMax); Console.Write("Array after ExtractMaximum : "); ArrayHelpers.PrintIntArray(arr); maxHeap.MaxHeapInsert(arr, 10); Console.Write("Array after Inserting 10 value : "); ArrayHelpers.PrintIntArray(arr); }
public static void MinHeapHelper() { int[] arr = { 4, 5, 1, 6, 7, 3, 2 }; Console.Write("Input Array for the MaxHeap problem : "); ArrayHelpers.PrintIntArray(arr); BinaryHeap minHeap = new BinaryHeap(); minHeap.BuildMinHeap(arr); int?minValue = minHeap.Maximum(arr); Console.WriteLine("Minimum value in the heap is : {0}", minValue); int extractMin = minHeap.ExtractMinimum(arr); Console.WriteLine("Extract Minimum value in the heap is : {0}", extractMin); Console.Write("Array after ExtractMinimum : "); ArrayHelpers.PrintIntArray(arr); minHeap.MinHeapInsert(arr, 1); Console.Write("Array after Inserting 0 value : "); ArrayHelpers.PrintIntArray(arr); //int[] arr = { 10, 8, 9, 7, 6, 5, 4 }; //Console.Write("Input Array for the problem : "); //ArrayHelpers.PrintIntArray(arr); //BinaryHeap heap = new BinaryHeap(); //// heap.PerformHeapSort(arr); //heap.BuildMinHeap(arr); }