Design an algorithm to print a binary tree, level by level, starting from the root.
We can print the binary tree, levelwise, using a \( queue \).
public static void printBinaryTreeByLevel(Node node){ Queue queue = new LinkedList (); queue.add(node); while(queue.size() > 0){ Node currentNode = queue.remove(); System.out.println(currentNode.value + “ ”); if(currentNode.left! = null) queue.add(currentNode.left); if(currentNode.right! = null) queue.add(currentNode.right); } }