Esempio n. 1
0
        public static void Main(string[] args)
        {
            var heap = new MinHeap <int>();

            for (int i = 0; i < 15; i++)
            {
                if (i % 2 == 0)
                {
                    i *= -1;
                }
                heap.Insert(i);
            }
            Console.WriteLine(heap.Count);
            Console.WriteLine(heap.ExtractMin());
            Console.WriteLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var numbers = new int[] { 1, 5, 2, 14, 5, 1, 0 };

            var heap = new MinHeap <int>();

            foreach (var item in numbers)
            {
                heap.Insert(item);
            }

            while (heap.Count > 0)
            {
                Console.WriteLine(heap.ExtractMin());
            }
        }
 public void Add(string value, int priority)
 {
     heap.Insert(priority, value);
 }