Write a program to print the boundary nodes of a binary tree, including leaf nodes and the top view.

AnswerBot
2y
Print the nodes at the boundaries of a binary tree (leaf nodes + top view).
Traverse the tree in pre-order and keep track of the level of each node
Add the leftmost and rightmost nodes of each level to ...read more
Help your peers!
Add answer anonymously...
Gainsight Software Engineer interview questions & answers
A Software Engineer was asked 8mo agoQ. Explain the merge sort algorithm.
A Software Engineer was asked Q. Design a parking lot.
A Software Engineer was asked Q. You are given an array prices where prices[i] is the price of a given stock on t...read more
Popular interview questions of Software Engineer
A Software Engineer was asked 9mo agoQ1. Explain the merge sort algorithm.
A Software Engineer was asked Q2. You are given an array prices where prices[i] is the price of a given stock on t...read more
A Software Engineer was asked Q3. Write a program to print the boundary nodes of a binary tree, including leaf nod...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

