Regarding Time Complexity

what will be the time complexity if we solve it using recursion.
will the time complexity be o(n) ? .

i have solved it using recursion

#include <bits/stdc++.h>

using namespace std;

void _pair(int a[], int n, int key)
{
if (n == 1)
{
return;
}
int fe = a[0];
for (int i = 1; i < n; i++)
{
if (fe + a[i] == key)
{
cout << fe << “,” << a[i] << endl;
break;
}
}
_pair(a + 1, n - 1, key);
}

int main()
{
int a[8] = {1, 3, 5, 7, 10, 11, 12, 13};
int key = 16;
_pair(a, 8, key);
return 0;
}

@asifkarim073 this approach has the time complexity of O(n^2) because in the worst case, you will call the function for all the n. And in each iteration you are traversing the array from 1 to n. Using recursion here instead of iterartion increases the space complexity as well(because the call stack will keep piling up on top of each other until the answer is found).