Given a Binary Tree, find the maximum width of it. Maximum width is defined as the maximum number of nodes in any level.
For example, maximum width of following tree is 4 as there are 4 nodes at 3rd level.
/ \ / \
4 5 6 7
The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains two lines of input. The first line contains number of edges. The second line contains relation between the nodes.
For each testcase, in a new line, print the maximum width.
You don't have to read any input. Just complete the function getMaxWidth() that takes node as parameter and returns the maximum width.
1 <= T <= 30
1 <= edges <= 100
1 <= nodes values <= 1000
1 2 R 1 3 L
10 20 L 10 30 R 20 40 L 20 60 R
Testcase1: The tree is
The second level has 2 nodes and hence the width is 2.
Testcase2: The tree is
Both second and third level have 2 nodes and hence max width is 2.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.