title: Recursive C Program Linearly Search Element Given Array
signature: recursive_c_program_linearly_search_element_given_array <- function(arr, l, r, x) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, l, r, x, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, l, r, x), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(10L, 74L, 5L), 0L, 2L, 1L, 
          -1L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-90L, 72L, 36L, 96L, 42L, 0L, -66L, 5L), 0L, 7L, 96L, 
          3L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 5L), 0L, 1L, -1L, 
          -1L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(99L, 70L, 67L, 5L), 0L, 3L, 3L, 
          -1L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-98L, -98L, -26L, -26L, -24L, -18L, -16L, 80L, 5L), 0L, 8L, 80L, 
          7L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 1L, 1L, 1L, 0L, 1L, 5L), 0L, 6L, 1L, 
          0L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(1L, 5L, 12L, 12L, 17L, 17L, 12L, 95L, 96L, 98L, 5L), 0L, 0L, 12L, 
          -1L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(50L, -70L, -30L, -54L, 6L, -10L, 70L, 84L, 5L), 0L, 8L, 27L, 
          -1L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 1L, 5L), 0L, 2L, 14L, 
          -1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(59L, 21L, 28L, 3L, 14L, 5L), 0L, 5L, 28L, 
          2L
      )))
  
  }
  
  main()
source_py: def recursive_c_program_linearly_search_element_given_array(arr, l, r, x):
      if (r < l):
          return (- 1)
      if (arr[l] == x):
          return l
      if (arr[r] == x):
          return r
      return recursive_c_program_linearly_search_element_given_array(arr, (l + 1), (r - 1), x)
source_cpp: int recursive_c_program_linearly_search_element_given_array(vector<int> arr, int l, int r, int x) {
    if ( r < l ) return - 1;
    if ( arr [ l ] == x ) return l;
    if ( arr [ r ] == x ) return r;
    return recursive_c_program_linearly_search_element_given_array ( arr, l + 1, r - 1, x );
  }