static int maxHeight ( int a [ ] , int n ) {
  node rootA = null ;
  rootA = insert ( rootA , a [ 0 ] ) ;
  for ( int i = 1 ;
  i < n ;
  i ++ ) rootA = insert ( rootA , a [ i ] ) ;
  node rootB = null ;
  rootB = insert ( rootB , a [ n - 1 ] ) ;
  for ( int i = n - 2 ;
  i >= 0 ;
  i -- ) rootB = insert ( rootB , a [ i ] ) ;
  int A = maxDepth ( rootA ) - 1 ;
  int B = maxDepth ( rootB ) - 1 ;
  return Math . max ( A , B ) ;
}

static int maxHeight ( int a [ ] , int n ) { node rootA = null ; rootA = insert ( rootA , a [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) rootA = insert ( rootA , a [ i ] ) ; node rootB = null ; rootB = insert ( rootB , a [ n - 1 ] ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) rootB = insert ( rootB , a [ i ] ) ; int A = maxDepth ( rootA ) - 1 ; int B = maxDepth ( rootB ) - 1 ; return Math . max ( A , B ) ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (null_literal))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (decimal_integer_literal)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (identifier))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (null_literal))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (identifier))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))