Example #1
0
 public void TestInsertionAndSortDescending()
 {
     var heap = new Heap(false);
     new[] { 4, 1, 7, 6, 5, 8 }.ToList().ForEach(heap.Insert);
     List<int> result = heap.GetSorted();
     result.ForEach(x => Console.Write("{0} ", x));
 }
Example #2
0
        public void TestPop()
        {
            var heap = new Heap(new List<int> { 4, 1, 7, 6, 5, 8 });
            int capacity = heap.Capacity();
            for (int i = 0; i < capacity; i++)
            {
                List<int> result = heap.GetSorted();
                result.ForEach(x => Console.Write("{0} ", x));
                Console.WriteLine();

                heap.Pop();
            }
        }
Example #3
0
 public void TestHeapify()
 {
     var heap = new Heap(new List<int> {4, 1, 7, 6, 5, 8});
     List<int> result = heap.GetSorted();
     result.ForEach(x => Console.Write("{0} ", x));
 }