@@ -0,0 +1,1412 @@
+package data_structures.trees;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * You are given a pointer root pointing to the root of a binary tree. You need%0D%0A * to print the level order traversal of this tree. In level order traversal, we%0D%0A * visit the nodes level by level from left to right.%0D%0A * For example:%0D%0A * %0D%0A *      3%0D%0A *    /   %5C%0D%0A *   5     2%0D%0A *  / %5C   /%0D%0A * 1   4 6%0D%0A * For the above tree, the level order traversal is 3 -%3E 5 -%3E 2 -%3E 1 -%3E 4 -%3E 6.%0D%0A * %0D%0A * Input Format: %0D%0A * First line contains T, the number of test cases. Next T lines contain an%0D%0A * integer data to be added to the binary search tree.%0D%0A * %0D%0A * Output Format: %0D%0A * Print the values of the level order traversal separated by spaces.%0D%0A * %0D%0A * Sample Input:%0D%0A *      3%0D%0A *    /   %5C%0D%0A *   5     2%0D%0A *  / %5C   /%0D%0A * 1   4 6%0D%0A * %0D%0A * Sample Output: %0D%0A * 3 5 2 1 4 6%0D%0A */%0D%0Apublic class LevelOrderTraversal %7B%0D%0A%0D%0A%09void LevelOrder(Node root) %7B%0D%0A%09%09int h = getHeight(root);%0D%0A%09%09for (int i = 1; i %3C= h; i++) %7B%0D%0A%09%09%09printLevel(root, i);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09void printLevel(Node root, int level) %7B%0D%0A%09%09if (root == null) %7B%0D%0A%09%09%09return;%0D%0A%09%09%7D%0D%0A%09%09if (level == 1) %7B%0D%0A%09%09%09System.out.print(root.data + %22 %22);%0D%0A%09%09%7D else if (level %3E 1) %7B%0D%0A%09%09%09printLevel(root.left, level - 1);%0D%0A%09%09%09printLevel(root.right, level - 1);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09int getHeight(Node root) %7B%0D%0A%09%09if (root == null) %7B%0D%0A%09%09%09return 0;%0D%0A%09%09%7D else %7B%0D%0A%09%09%09return 1 + Math.max(getHeight(root.left), getHeight(root.right));%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%7D

Add LevelOrderTraversal