I have a recursive function, and I’m trying to figure out it’s complexity.
denote P(n) – the runtime of the function (when given the parameter n).
I know that : P(n)=n+(n-1)*P(n-1) [p(1)=1]
How can I express P(n) without using P(…) ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That would be O(nn). Notice that if you start expanding the expression, you’ll get an element with power of n increased by 1 on each iteration. This will be the dominant element so others can be dropped for the O() calculation. For a more formal solution see the link provided by @Max.