title: Recursion algorithms pseudocode
body: <p>I want to create a recursion pseudocode that will executed in O(logn) complexity
  and i want it to find the lower f(i) &lt; 0 and f[1....n] which f(1) >0 and f(n)&lt;0</p>
  
  <pre><code>prodedure fanc(A[n] , p , q )  //(this is my array,first digit of A ,last digit of A)
  if A[n/2] &gt;= 0
       return fanc(A[n/2] , A[n/2] , A[n-1])
  else
       return fanc(A[n/2] , A[0] , A[n/2 -1])
  if p&lt;q
     print p
  else
     print q
  </code></pre>
  
  <p>I know that somehow i have to end the recursion. Also i would like to know if i am in the correct path and if u have any good thoughts for this problem!</p>
  
  <hr>
  
  <p>Better text of assignment copied from <a href="https://stackoverflow.com/questions/42935621/algorithm-in-ologn">https://stackoverflow.com/questions/42935621/algorithm-in-ologn</a>:</p>
  
  <blockquote>
    <p>Let an integer function f:{1,2,3...n} be monotonic and defined in {1,2,3...n} and suppose that f(1) > 0 and f(n) &lt; 0. We would like to find the smallest integer i with f(i) &lt; 0. Design an algorithm for this purpose that run in O(logn).</p>
  </blockquote>