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)

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation