def f(n):
if n < 100000:
return 0;
for(int i = 0; i < n*n; i++){
return f(n-1)
}
What is the time complexity?
My answer is $O((n!)^2)$. Here's my thought process:
The for loop will be running $n^2$ the first time.
However, during the first loop (i.e., $i = 0$), it will call $f(n-1)$, hence the next for loop will be $(n-1)^2$.
This will keep going until $n <10000$ (base case). Assuming $n$ is very huge, the number of calls for each function to base case is essentially $n$ times.
Now, considering all the for loops, the total number of calls is essentially $n^2 \cdot (n-1)^2 \cdot (n-2)^2 \cdots 1!$ (there will be a total of $n$ times multiplication, and each multiplication will be $n-1$ of the previous one because of $f(n-1)$ call).