Challenge: Print Level Order Line by Line Using Two Queues

Let’s print the level-order traversal of a binary tree using two queues.

Problem

Given a binary tree, perform a level-order line-by-line traversal by completing the PrintLevelOrderLineByLine() function. This time, try to solve the problem using two queues. 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

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.