title: Recursive and Iterative Binary Search: Which one is more efficient and why?
body: <p>I have written the algorithms for recursive and iterative binary search:</p>
  
  <p>Recursive</p>
  
  <pre><code>AlgorithmBinSrch(a, i,l,x)
  // Given an array a[i :l] of elementsin nondecreasing
  // order,1&lt;i &lt;=l,determinewhetherx is present,and
  // if so,return j suchthat x = a[j];elsereturn 0.
  {
      if (l =i) // If Small(P) {
          if(x=a[i]) 
              return i;
          else 
              return 0;
      } else { // ReduceP into a smallersubproblem.
          mid:=[(i+l)/2]; 
          if (x = a[mid]) 
              return mid;
          else if (x &lt;a[mid]) 
              returnBinSrch(a,i,mid-1,x);
          else
              returnBinSrch(a,mid1+,l,x);
      } 
  }
  </code></pre>
  
  <p>Iterative</p>
  
  <pre><code>// Given an array a[1:n] of elementsin nondecreasing
  // order,n &gt;=0,determine whether x is present,and
  // if so,return j suchthat x = a[j];elsereturn 0.
  {
      low :=1;high :=n;
      while (low&lt;=high) {
          mid:= [(low+high)/2];
          if (x &lt;a[mid])
              high :=mid-1;
          else if (x &gt;a[mid])
              low :=mid+ 1;
          else 
              return mid;
      } 
      return 0;
  }
  </code></pre>
  
  <p>Which one of them will be more efficient and how does one find that. Should <code>count</code> statements be added to count number of steps in each and based on that can efficiency be determined?</p>