Recursive algorithm time complexity
<p>I am trying two find the time complexity of a recursive function that merges <em>n</em> number of files. </p>

<p>My solution is <em>T(n)=kc+T(n-(k+1))</em> where <em>n</em> > 0, <em>T(n)=T(0)</em> where <em>n</em>=0. </p>

<p>Is this correct or is there any other way of finding the time complexity?</p>

<p>Here is the pseudo code,</p>

<pre><code>//GLOBAL VARIABLES
int nRecords = 0...k; //assume there are k records
int numFiles = 0...n; //assume there are n files
String mainArray[0...nRecords]; //main array that stores the file records

void mergeFiles(numFiles) { //params numFiles
  fstream file; //file variable
  if (numFiles == 0) {
    ofstream outfile; //file output variable
    outfile.open(directory / mergedfile); // point variable to directory
    for (int i = 0; i &lt; sizeOf(mainArray); i++) {
      oufile &lt;&lt; mainArray[i]; // write content of mainArray to outfile
    }
    outfile.close(); //close once operation is done
  } else {
    int i = 0; //file index counter
    file.open(directory / nextfile); //open file to be read

    if (file.isOpen()) {
      while (!file.eof() &amp;&amp; i &lt; sizeOf(mainArray)) {
        file &gt;&gt; mainArray[i]; //copy contents of file to mainArray
        i++; //increase array index
      }
    }
    file.close(); //close once operation is done
    mergeFiles(numFiles - 1); //recurse function
  }
}

int main() {
  mergeFiles(numFiles); //call mergeFile function to main
}
</code></pre>