engineering recuitment NIC NIELIT Scientist B 2023 Mock Test Algorithms Asymptotic Worst Case Time and Time Complexity Recurrences
निम्नलिखित पुनरावर्ती फलन पर विचार करें:
int sum(int n)
{
if (n == 1)
{
return 1;
}
return 1 + sum(n-1);
}
उपरोक्त कोड की समय जटिलता क्या है?1
Θ (n2)
2
Θ (n)
3
Θ (log n)
4
Θ (n log n)