static void Main()
    {
        Tree <int> tree             = TreeReader.ReadIntegerTreeValues();
        int        deepestNodeValue = GetDeepestNode(tree);

        Console.WriteLine($"Deepest node: {deepestNodeValue}");
    }
Beispiel #2
0
    static void Main()
    {
        Tree <int> tree = TreeReader.ReadIntegerTreeValues();

        List <int> longestPath = new List <int>();
        List <int> currentPath = new List <int>();

        FindLongestPath(tree, longestPath, currentPath);

        Console.WriteLine($"Longest path: {string.Join(" ", longestPath)}");
    }
Beispiel #3
0
    static void Main()
    {
        Tree <int> tree = TreeReader.ReadIntegerTreeValues();

        List <int> result = new List <int>();

        GetLeaves(tree, result);
        result.Sort();

        Console.WriteLine($"Leaf nodes: {string.Join(" ", result)}");
    }
    static void Main()
    {
        Tree <int> inputTree    = TreeReader.ReadIntegerTreeValues();
        int        requestedSum = int.Parse(Console.ReadLine());

        List <Tree <int> > subTrees = GetSubtreesWithGivenSum(inputTree, requestedSum);

        Console.WriteLine($"Subtrees of sum {requestedSum}:");
        subTrees.ForEach(st =>
        {
            st.Each(node => Console.Write($"{node} "));
            Console.WriteLine();
        }
                         );
    }
Beispiel #5
0
    static void Main()
    {
        Tree <int> inputTree = TreeReader.ReadIntegerTreeValues();

        int requestedSum            = int.Parse(Console.ReadLine());
        List <List <int> > allPaths = new List <List <int> >();
        List <int>         path     = new List <int>();

        GetAllPathsWithAGivenSum(inputTree, allPaths, path, 0, requestedSum);

        Console.WriteLine($"Paths of sum {requestedSum}:");
        foreach (var currentPath in allPaths)
        {
            Console.WriteLine(string.Join(" ", currentPath));
        }
    }
Beispiel #6
0
 static void Main()
 {
     inputTree = TreeReader.ReadIntegerTreeValues();
     Console.WriteLine($"Root node: {inputTree.Value}");
 }