title: Determining Time Complexity of a Recursive Function Calling From inside a Loop
body: <p>I am not sure, is that question previously asked in SO or not. Well, I was checking frequency of a char in an array. I am pretty weak in determining complexity, so I thought this community can help me to get the point! I am very much sorry, if I posting it with some abstraction! If anyone can help me it will be great! </p>
  
  <p>Here, is my code:</p>
  
  <pre><code>class SearchAChar{
  private static int getOccurance(char [] a, char k, int l, int r, int count){
      if(l == r) return count;
  
      if(a[l] == k){a[l]='0';count++;}
  
      return getOccurance(a, k, l+1, r, count);   
  }
  public static void main(String [] args){
      char [] arr = {'a', 'e', 'b', 'c', 'b', 'c', 'd','a'};
  
      for(int i=0; i&lt;arr.length; i++){
          if(arr[i] == '0') continue;
          System.out.println("Occurance of : " +arr[i] + " is "+ getOccurance(arr, arr[i], i, arr.length, 0) +" times!");
      }
  }
  }
  </code></pre>
  
  <p>what should be the run-time complexity of this problems??  </p>