/// <summary>
 /// 层级遍历整树(非递归)
 /// </summary>
 /// <param name="tree"></param>
 public static void LevelTraverseAllTreeNoRecursion(this LinkedBinaryTree tree)
 {
     if (tree == null || tree.Root == null)
     {
         return;
     }
     LevelTraverseNoRecursion(tree.Root);
 }
 /// <summary>
 /// 后序遍历整树(递归)
 /// </summary>
 /// <param name="tree"></param>
 public static void PostTraverseAllTreeByRecursion(this LinkedBinaryTree tree)
 {
     if (tree == null || tree.Root == null)
     {
         return;
     }
     PostTraverse(tree.Root);
 }
Beispiel #3
0
 public static void PrintProps <TNode, T>([NotNull] this LinkedBinaryTree <TNode, T> thisValue)
     where TNode : LinkedBinaryNode <TNode, T>
 {
     Console.WriteLine();
     Console.WriteLine($"{Yellow("Dimensions:")} {Underline(thisValue.Count.ToString())} x {Underline(thisValue.GetHeight().ToString())}.");
     Console.WriteLine($"{Yellow("Balanced:")} {thisValue.IsBalanced().ToYesNo()}");
     Console.WriteLine($"{Yellow("Valid:")} {thisValue.Validate().ToYesNo()}");
     Console.WriteLine($"{Yellow("Minimum:")} {thisValue.Minimum()} {Yellow("Maximum:")} {thisValue.Maximum()}");
 }
Beispiel #4
0
 public static void Print <TNode, T>([NotNull] this LinkedBinaryTree <TNode, T> thisValue)
     where TNode : LinkedBinaryNode <TNode, T>
 {
     Console.WriteLine();
     thisValue.WriteTo(Console.Out);
 }
Beispiel #5
0
 public static void PrintWithProps <TNode, T>([NotNull] this LinkedBinaryTree <TNode, T> thisValue)
     where TNode : LinkedBinaryNode <TNode, T>
 {
     PrintProps(thisValue);
     thisValue.Print();
 }