Leftmost and rightmost nodes of binary tree

0

0 votes
Easy-Medium
Problem

Given a Binary Tree, Print the corner nodes at each level. The node at the leftmost and the node at the rightmost.

Input: The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an intger n denoting the number of Nodes(except Root). The next line contains the nodes of the binary tree.

Output: Print the corner nodes ( nodes at the leftmost and nodes at the rightmost) at each level.

Constraints: 1<=T<=100 1<=data of each node<=100 1<=n<=100

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?