Example #1
0
        static void Main(string[] args)
        {
            IntFibonacciHeap heap = ReadFile("input.txt");

            if (heap != null && !heap.IsEmpty())
            {
                ProcessHeap(heap);
            }
            WriteFile(heap, "output.txt");
        }
Example #2
0
        private static IntFibonacciHeap ReadFile(string fileName)
        {
            IntFibonacciHeap heap = new IntFibonacciHeap();

            using (StreamReader reader = new StreamReader(fileName))
            {
                var numbersStr = reader.ReadLine();
                heap = new IntFibonacciHeap(numbersStr);
            }
            return(heap);
        }
Example #3
0
 private static void WriteFile(IntFibonacciHeap heap, string fileName)
 {
     using (StreamWriter writer = new StreamWriter(fileName))
     {
         List <String> trees = new List <string>();
         trees = heap.HeapWalk();
         foreach (string treeStr in trees)
         {
             writer.WriteLine(treeStr);
         }
     }
 }
Example #4
0
        private static void ProcessHeap(IntFibonacciHeap heap)
        {
            heap.ExtractMin();
            IntFibonacciHeap secondHeap = ReadFile("input2.txt");

            if (secondHeap != null && !secondHeap.IsEmpty())
            {
                secondHeap.ExtractMin();
                heap.Union(secondHeap);
            }

            //Console.WriteLine(heap.GetMinNode().Key);
            //Console.WriteLine(heap.GetMinNode().Key);
            //heap.DecreaseKey(heap.GetMinNode(), 1);
            //Console.WriteLine(heap.GetMinNode().Key);
            //heap.Delete(heap.GetMinNode());
        }