educational course/tutorialoutlet.com educational course/tutorialoutlet.com | Page 74

{ int largest = intArray [ 0 ]; for ( int i = 1 ; i & lt ; intArray . length ; i ++) { if ( intArray [ i ] & gt ; largest ) { largest = intArray [ i ]; for ( int j = 0 ; j & lt ; i ; j ++) intArray [ j ] = largest ; } else intArray [ i ] = largest ; } } Page 3 of 5 Question 3 ( 10 marks ) Recursion : Write a recursive function that will calculate the height of a binary tree . root1 D B A root2 E C Note : root1 and root2 are instances of the class BinNode : public class BinNode { public char value ; public BinNode left ; public BinNode right ; } Thus , the following statements would lead to the underlined output : Example 1 : System . out . println ( treeHeight ( root1 ) ); 3 Example 2 : System . out . println ( treeHeight ( root2 ) ); 1 Please write your method on the following page . Page 4 of 5 public static inttreeHeight ( BinNode current ) ---------------------------------------------------------------------------------------