Example #1
0
        /// <summary>
        /// Recherche du noeud précedent
        /// </summary>
        /// <param name="a">Tree</param>
        /// <returns>Le neodu précédent</returns>
        public static Tree TreeSearchPredecessor(Tree a)
        {
            if (a == null)
            {
                return(null);
            }
            if (a.Left != null)
            {
                return(Tree.TreeMaximumValue(a.Left));
            }

            Tree y = a.Parent;

            while (y != null && a == y.Left)
            {
                a = y;
                y = y.Parent;
            }

            return(y);
        }