public static void Main(string[] args) { Console.WriteLine("Creating Binary Tree ... !"); var root = BinaryTreeHelper.InitializeBinaryTreeV2(); var coll = LevelTraversal(root); var inverted = Invert(root); var coll2 = LevelTraversal(inverted); bool isSymmetric = true; for (int i = 0; i < coll.Count; i++) { if (coll[i] != coll2[i]) { isSymmetric = false; break; } } Console.WriteLine(isSymmetric); Console.WriteLine("Trying another approach !"); Console.WriteLine("Creating Binary Tree ... !"); root = BinaryTreeHelper.InitializeBinaryTreeV2(); Console.WriteLine(IsSymmetricAnother(root)); }
static void Main(string[] args) { Console.WriteLine("Creating Binary Tree ... !"); var root = BinaryTreeHelper.InitializeBinaryTreeV2(); Console.WriteLine("Diameter : " + Diameter(root)); }
static void Main(string[] args) { Console.WriteLine("Creating Binary Tree ... !"); var root = BinaryTreeHelper.InitializeBinaryTreeV2(); Console.WriteLine("Min Depth : " + Minimum(root, root)); }
static void Main(string[] args) { Console.WriteLine("Creating Binary Tree ... !"); var root = BinaryTreeHelper.InitializeBinaryTreeV2(); Console.WriteLine("Calculating height ... !"); Console.WriteLine(Height(root)); }
static void Main(string[] args) { Console.WriteLine("Creating Binary Tree ... !"); var root = BinaryTreeHelper.InitializeBinaryTreeV2(); LevelOrderDisplay(root); root = Remove(root); LevelOrderDisplay(root); InOrder(root); }
static void Main(string[] args) { Console.WriteLine("Creating Binary Tree ... !"); var root = BinaryTreeHelper.InitializeBinaryTreeV2(); Console.WriteLine("Level Traversal ... !"); LevelTraversal(root); Console.WriteLine(); LevelOrderDisplay(root); Console.WriteLine(); }
static void Main(string[] args) { Console.WriteLine("Creating Binary Tree ... !"); var root = BinaryTreeHelper.InitializeBinaryTreeV2(); Console.WriteLine("Level Order Display"); LevelOrderDisplay(root); Console.WriteLine("Nodes at ODD level, root treated as level 1"); Odd(root); }
static void Main(string[] args) { Console.WriteLine("Creating Binary Tree ... !"); var root = BinaryTreeHelper.InitializeBinaryTreeV2(); LevelOrderDisplay(root); int k = 2; var nodes = KthLevel(root, k); Console.WriteLine("Nodes at level {0} are :-", k); foreach (var item in nodes) { Console.Write(item.Value + " "); } Console.WriteLine(); }
static void Main(string[] args) { //https://www.udemy.com/course/cpp-data-structures-algorithms-prateek-narang/learn/quiz/5293164#overview Console.WriteLine("Creating Binary Tree ... !"); var root = BinaryTreeHelper.InitializeBinaryTreeV2(); var targetSum = 22; List <int> temp = new List <int>(); TargetSum(root, targetSum, temp, 0); foreach (var outer in output) { foreach (var inner in outer) { Console.Write(inner + " "); } Console.WriteLine(); } }