Challenge: Print Level Order Line by Line Using Two Queues

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


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.


A binary tree.


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

Sample input

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