예제 #1
0
        public static void Test()
        {
            int[] array = { 3, 1, 2, 5, 6, 7, 9, 10, 4, 8 };
            MinPQ pq    = new MinPQ(array);

            for (int i = 0; i < array.Length; i++)
            {
                Console.Write(pq.DeleteMin() + " ");
            }
            Console.WriteLine();

            pq = new MinPQ(2);
            for (int i = 0; i < array.Length; i++)
            {
                pq.Insert(array[i]);
            }
            while (pq.Count() > 0)
            {
                Console.Write(pq.DeleteMin() + " ");
            }
            Console.WriteLine();
        }
예제 #2
0
        public static void Test()
        {
            int[] array = { 3, 1, 2, 5, 6, 7, 9, 10, 4, 8};
            MinPQ pq = new MinPQ(array);
            for (int i = 0; i < array.Length; i++)
                Console.Write(pq.DeleteMin() + " ");
            Console.WriteLine();

            pq = new MinPQ(2);
            for (int i = 0; i < array.Length; i++)
                pq.Insert(array[i]);
            while (pq.Count() > 0)
                Console.Write(pq.DeleteMin() + " ");
            Console.WriteLine();
        }