Print Level Wise — Coding Question

Problem Question:

For a given a Binary Tree of type integer, print the complete information of every node, when traversed in a level-order fashion.

Input Format:

The first and the only line of input will contain the node data, all separated by a single space. Since -1 is used as an indication whether the left or right node data exist for root, it will not be a part of the node data.

Output Format:

Information of all the nodes in the Binary Tree will be printed on a different line where each node will follow a format of D:L:X,R:Y, without any spaces in between.

Sample Input :

8 3 10 1 6 -1 14 -1 -1 4 7 13 -1 -1 -1 -1 -1 -1 -1

Sample Output :



Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.




Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Git Branching Naming Convention: Best Practices

13. Solution Exploration and Evaluation Tables

Launching and Configuring Kubernetes in different platforms

Setup Single-node Kubernetes Cluster on a Home Lab server using k0s

Secure SD-WAN Fortinet — Enterprise use cases

ANACITY, a cost-saving software for Owner Association Management Companies

Please vote for the latest Community Superblock!

Can individuals write code?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Upskilling students for tech placements!

More from Medium

Leetcode Q525. Contiguous Array (Q444)

Solutions for LeetCode 743

Buy a Shovel Coding Question

Ace Your Coding Interview- Blind 75 Solved and Explained — Part 4 Linked List