title: Why recursive Binary search sometimes cause stack overflow for some but not all non existing inputs?
body: <p>I'm implementing a recursive python binary search function That works fine for most inputs but seems to cause stack overflow for some but not all non existing list elements which I can't see why is this behavior
  the code is</p>
  <pre class="lang-py prettyprint-override"><code>def recursive_binary_search(start: int, end: int, search:int, array: list):
      &quot;&quot;&quot;
      :param start: start index
      :param end: end index
      :param search: integer to search find
      :param array: Sorted array to search
      :return: True if found, False if Not
      &quot;&quot;&quot;
  
      if (end == start) and array[start] != search: return False
      if (end == start) and array[start] == search: return True
  
      middle_index = (end+start)//2
      if array[middle_index] == search: return True
  
      elif array[middle_index] &gt; search:
          res = recursive_binary_search(start, middle_index-1, search, array)
          return res
      elif array[middle_index] &lt; search:
          res = recursive_binary_search(middle_index+1, end, search, array)
          return res
  
  </code></pre>
  <p>the list is <code>sorted_list = [1, 2, 3, 4, 4, 7, 9, 10, 14, 80]</code> inputs seeming to cause overflow are <code>6</code> <code>11</code> and return <code>False</code> as normal for inputs like <code>8</code> and <code>100</code> and <code>15</code> . The function is called as <code>print(recursive_binary_search(0, len(sorted_list)-1, 11, sorted_list))</code></p>