public void testCalculateAmortizedComplexityOfRandomTreesInLoop()
        {
            int minNumberOfNodes = 50, maxNumberOfNodes = 100, numberOfTrees = 50;
            bool writeResultsToFile = true;
            FileStream fs = new FileStream("./amortizedAnalysisResults-" +
                DateTime.Now.Year + "-" +
                DateTime.Now.Month + "-" +
                DateTime.Now.Day + "_" +
                DateTime.Now.Hour + "." +
                DateTime.Now.Minute + "." +
                DateTime.Now.Second +
                ".txt", FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);
            Random rnd = new Random();

            if (minNumberOfNodes > maxNumberOfNodes || minNumberOfNodes < 0 || maxNumberOfNodes < 1 || numberOfTrees < 1)
                Assert.Fail("The configuration is incorrect");

            for (int i = 0; i < numberOfTrees; i++)
            {
                Debug.WriteLine("-----------------------------------------------------------------");
                var numberOfNodes = rnd.Next(minNumberOfNodes, maxNumberOfNodes);
                Debug.WriteLine("Generating " + numberOfTrees + " random trees with " + numberOfNodes + " Nodes");
                BinaryTree tree = new BinaryTree(numberOfNodes);

                Debug.WriteLine("Tree was generated from the following values: { " + string.Join(",", tree.nodeValues) + "} (" + tree.nodeValues.Length + " nodes)");

                int amortizedComplexity = tree.calculateAmortizedComplexity();
                Assert.AreEqual(2 * (tree.nodeValues.Length - 1), amortizedComplexity); // the complexity is always 2*(n-1)

                Debug.WriteLine("Amortized complexity: " + amortizedComplexity);
                Debug.WriteLine("Is amortized complexity right: " + (2 * (tree.nodeValues.Length - 1) == amortizedComplexity).ToString());

                if (writeResultsToFile)
                    sw.WriteLine(tree.nodeValues.Length + "," + amortizedComplexity);
            }
            sw.Close();
            fs.Close();
        }
 public void testCalculateAmortizedComplexityOfRandomTreeOfHundredNodes()
 {
     BinaryTree tree = new BinaryTree(100); // will generate Nodes with values [1, 100] in random order
     Assert.AreEqual(2 * (tree.nodeValues.Length - 1), tree.calculateAmortizedComplexity()); // the complexity is always 2*(n-1)
 }