Given a binary tree, write a recursive method to return the maximum element.

Examples: 1 / \ 2 3 ==> 7 / \ / \ 4 5 6 7

Need a **hand?** Try out these hints, one at a time.

The key here is to compare

`left, right and root`

elements recursively at each step and return the maximum element at the end of the traversal.
1. Maintain 3 variables - `ld`

,`rd`

and `rtd`

- one to store the maximum element across the left set of nodes, the other to store the maximum element across right set of nodes and the third to store the root element.

2. Assign `findMax(root.left)`

to `ld`

.

3. Assign `findMax(root.right)`

to `rd`

.

4. And `root data`

to `rtd`

.

5. Compare these 3 variables and return the **max** of the three.

public int findMax(TreeNode root) { }

**C**

**Java**

**Python**