engineering recuitment NIC NIELIT Scientist B 2023 Mock Test Algorithms Asymptotic Worst Case Time and Time Complexity Recurrences
Consider the following recursive function:
int sum(int n)
{
if (n == 1)
{
return 1;
}
return 1 + sum(n-1);
}
What is the time complexity of the above code?1
Θ (n2)
2
Θ (n)
3
Θ (log n)
4
Θ (n log n)