I'm having problems calculating the complexity of the following recurrence equation.
It's quite difficult for me to solve it. Could anyone help me to solve this problem? Thanks in advance.
This is the same recurrence for the average case complexity of quicksort with solution
T(n)=O(n log n)
derivation here
Related
I was learning about time complexity recently and I was wondering time complexity of a algorithm to compute a^n. My answer will be O(n).
However, I was thinking about the divide and conquer method. As a^n/2 * a^n/2 = a^n. Is it possible to turn time complexity of an algorithm a^n into a algorithm with O(logn) time complexity but I was stuck thinking how would such an algorithm be and how would it works?
I would greatly appreciate if anyone could share their thoughts with me.
I've made a backtracking algorithm.
I've been asked to say what is the complexity of this Algo.
I know that the equation is T(n) = 2T(n-1) + 3(n_hat), where n_hat is the initial n. Meaning it doesn't decrease in each step.
The thing is that I'm getting quite lost on calculating this thing. I believe it's around 2**n * something. But my calculations are a bit confusing. Can you help me please? Thanks!
Let's expand this formula repeatedly by substituting into itself:
Dear friends here I am getting some confusion regarding time complexity of my algorithm. My algorithm has time complexity 3^(.5n). Is it correct way to write 3^(.5n) as (3^.5)^n. In one thesis I got it.
Yes, it is correct way. It is known identity for exponentiation
(a^b)^c = a^(b*c)
But what is relation of math formula to programming?
I need to solve the exact time complexity for the brute force version of the Traveling Salesman using a recurrence relation.
I've worked out the recurrence relation to be as follows:
T(n)=T(n-1)*(n-1)+1
But I'm having trouble reducing that that to a closed form of the function, and thus get the exact time complexity. Not for lack of trying either. It's looking like it's coming out as a binomial sequence but my algebra is a bit rusty.
If anyone could help or point me on the right path I would appreciate it.
Thanks!
Here are a few hints :
define R(n) = T(n)/(n-1)!
solve the recurrence for R(n)
express T(n) as a function of R(n)
Which algorithm for the knapsack problem has a O(2^n*n) complexity?
I've been asked to implement a solution for the knapsack problem.
I'm familiar with programming but not with asymptotic notation.
Can anybody advise me on which algorithm has a O(2^n*n) complexity?
O(n * 2^n) is the performance of the brute force algorithm (= just try all combinations), see http://en.wikipedia.org/wiki/Knapsack_problem#Meet-in-the-Middle_Algorithm