Beispiel #1
0
        private GeeksForGeeksNode GetInorderPredecessor(GeeksForGeeksNode node)
        {
            var current = node;

            while (current.Right != null)
            {
                current = current.Right;
            }
            return(current);
        }
Beispiel #2
0
        public int FindPredecessor(GeeksForGeeksNode node)
        {
            if (node.Left == null)
            {
                return(node.Value);
            }

            var predecessor = GetInorderPredecessor(node.Left);

            return(predecessor.Value);
        }