public static boolean isRotated ( int arr [ ] , int n ) {
  int l = 0 ;
  int r = n - 1 ;
  int pivot = - 1 ;
  if ( arr [ l ] > arr [ r ] ) {
    pivot = findPivot ( arr , l , r ) ;
    if ( l < pivot ) {
      while ( pivot > l ) {
        if ( arr [ pivot ] < arr [ pivot - 1 ] ) {
          return false ;
        }
        pivot -- ;
      }
    }
    else {
      pivot ++ ;
      while ( pivot < r ) {
        if ( arr [ pivot ] > arr [ pivot + 1 ] ) {
          return false ;
        }
        pivot ++ ;
      }
    }
    return true ;
  }
  else {
    return false ;
  }
}

public static boolean isRotated ( int arr [ ] , int n ) { int l = 0 ; int r = n - 1 ; int pivot = - 1 ; if ( arr [ l ] > arr [ r ] ) { pivot = findPivot ( arr , l , r ) ; if ( l < pivot ) { while ( pivot > l ) { if ( arr [ pivot ] < arr [ pivot - 1 ] ) { return false ; } pivot -- ; } } else { pivot ++ ; while ( pivot < r ) { if ( arr [ pivot ] > arr [ pivot + 1 ] ) { return false ; } pivot ++ ; } } return true ; } else { return false ; } }
(method_declaration (modifiers) type: (boolean_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: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (block (return_statement (false)))) (expression_statement (update_expression (identifier)))))) alternative: (block (expression_statement (update_expression (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (block (return_statement (false)))) (expression_statement (update_expression (identifier))))))) (return_statement (true))) alternative: (block (return_statement (false))))))