Challenge: Print a Tree in Level-order Line by Line Using a Queue

Try solving the problem of printing the binary tree using level-order traversal. Check if you can implement the solution using one queue.

Problem

Given a binary tree, perform a level-order traversal on it by completing the PrintLevelOrderLineByLine2()function. Try to solve this problem using one queue this time. For more information about the level order traversal, refer to this lesson.

Input

A binary tree.

Output

Display the level-order traversal of the tree on the console.

Sample input

Get hands-on with 1400+ tech skills courses.