コード例 #1
0
        public static void Run()
        {
            MaxHeap heap = new MaxHeap(5);

            heap.Insert(1, 0);
            heap.Insert(2, 0);
            heap.Insert(3, 0);
            heap.Insert(4, 0);
            heap.Insert(5, 0);
            heap.Print();
        }
コード例 #2
0
        public static void Main()
        {
            Console.WriteLine($"Given an array of size N. The task is to sort the array elements by completing " +
                              $"functions heapify() and buildHeap() which are used to implement Heap Sort.");

            var input = new int[] { 4, 1, 3, 9, 7 };

            MaxHeap heap = new MaxHeap();

            for (int i = 0; i < input.Length; i++)
            {
                heap.Insert(input[i]);
            }

            heap.PrintHeap();

            Console.ReadLine();
        }