title: Find Minimum Element In A Sorted And Rotated Array
signature: find_minimum_element_in_a_sorted_and_rotated_array <- function(arr, low, high) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, low, high, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, low, high), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(16L, 22L, 50L, 64L, 68L, 79L, 84L, 88L, 89L), 4L, 6L, 
          68L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(88L, -38L, 46L, 24L, -52L, -12L, -90L, 28L, 18L, 14L, -72L, 58L, -98L, 28L, -84L, 44L, -42L, -32L, -22L, -22L, -82L, -30L, 90L, 18L, 62L, 62L, 92L, 6L, 60L, 28L, -90L, 92L, 82L, 62L, 98L, -68L, 48L, -74L, -8L, 50L, 62L, 24L, 30L, -86L, 98L, -96L, -98L), 42L, 31L, 
          88L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 28L, 21L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(26L, 66L, 94L, 28L, 38L, 31L, 92L, 66L, 81L, 8L, 36L, 64L, 80L, 32L, 48L, 71L, 72L, 54L, 61L, 60L, 89L), 19L, 17L, 
          26L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-46L, -26L, -22L, -14L, 46L, 62L), 4L, 4L, 
          46L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 1L, 1L, 1L), 2L, 2L, 
          1L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(14L, 81L, 87L), 1L, 1L, 
          81L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(4L), 0L, 0L, 
          4L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 15L, 17L, 
          1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(3L, 41L, 40L, 53L, 82L, 9L, 90L, 43L, 90L, 59L, 37L, 21L, 92L, 98L, 36L, 99L, 35L, 67L, 24L, 29L, 40L, 31L, 46L, 12L, 29L, 8L, 93L, 67L, 44L, 83L, 71L, 29L, 22L, 32L, 33L, 11L, 44L, 97L, 84L, 44L, 8L, 10L, 31L, 50L, 22L, 8L), 42L, 31L, 
          3L
      )))
  
  }
  
  main()
source_py: def find_minimum_element_in_a_sorted_and_rotated_array(arr, low, high):
      if (high < low):
          return arr[0]
      if (high == low):
          return arr[low]
      mid = int(((low + high) / 2))
      if ((mid < high) and (arr[(mid + 1)] < arr[mid])):
          return arr[(mid + 1)]
      if ((mid > low) and (arr[mid] < arr[(mid - 1)])):
          return arr[mid]
      if (arr[high] > arr[mid]):
          return find_minimum_element_in_a_sorted_and_rotated_array(arr, low, (mid - 1))
      return find_minimum_element_in_a_sorted_and_rotated_array(arr, (mid + 1), high)
source_cpp: int find_minimum_element_in_a_sorted_and_rotated_array(vector<int> arr, int low, int high) {
    if ( high < low ) return arr [ 0 ];
    if ( high == low ) return arr [ low ];
    int mid = low + ( high - low ) / 2;
    if ( mid < high && arr [ mid + 1 ] < arr [ mid ] ) return arr [ mid + 1 ];
    if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) return arr [ mid ];
    if ( arr [ high ] > arr [ mid ] ) return find_minimum_element_in_a_sorted_and_rotated_array ( arr, low, mid - 1 );
    return find_minimum_element_in_a_sorted_and_rotated_array ( arr, mid + 1, high );
  }