Esempio n. 1
0
        public int GetMaxPath(Node n)
        {
            int left  = 0;
            int right = 0;
            int max   = n.GetData();

            if (n.GetLeft() != null)
            {
                left = GetMaxPath(n.GetLeft());
            }
            if (n.GetRight() != null)
            {
                right = GetMaxPath(n.GetRight());
            }
            if (left > right)
            {
                max += left;
            }
            else
            {
                max += right;
            }
            return(max);
        }