title: Linear search algorithm with recursive call?
body: <p>I am doing some exercises so that I can get through recursive stuff. One of these is I'm trying to re-write the linear search with recursion. Here it is:</p>
  
  <pre><code>int linearSearch(int a[], int n, int key)
  {
      if (n &lt; 0 ) 
      {
            return -1;
      }
      if(key == a[n-1])
      {
             return n - 1;
      } 
      linearSearch(a, n-1, key); // Line 1
  }
  </code></pre>
  
  <p>The code did not execute correctly if it does not have <code>return</code> statement. I dont understand why we need to put the <code>return</code> statement at line 1? Is all we need to call recursively in this case just to decrease n by 1?</p>