 Size of Binary Tree
##### Submissions: 16602   Accuracy: 60.47%   Difficulty: Basic   Marks: 1

Given a binary tree, count number of nodes in it. For example, count of nodes in below tree is 4.

1
/      \
10      39
/
5
Your task is to complete the function getSize() which accepts root node of the tree, and returns the size.

Input:
The input line contains T, denoting the number of testcases. Each testcase contains two lines. The first line contains E, number of edges. The second line contains E+1 nodes of the binary tree separated by space. The left and right nodes of tree are referred as such 1 2 L 1 3 R i.e 2 is left of 1 and 3 is right of 1.

Output:
For each testcase in new line, print the number of nodes.

Since this is a functional problem you don't have to worry about input, you just have to complete the function getSize().

Constraints:
1 <= T <= 30
1 <= E <= 100
1 <= Data of a node <= 1000

Example:
Input:

2
2
1 2 L 1 3 R
4
10 20 L 10 30 R 20 40 L 20 60 R

Output:
3
5

Explanation:
Testcase 1:
First case represents a tree with 3 nodes and 2 edges where root is 1, left child of 1 is 2 and right child of 1 is 3

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: kartik

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.