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)
Related
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
If I know then recurrence equation and the complexity of the recurrence. please suggest an example
The Recurrence Equation, also known as the Difference Equation would involve using recursive techniques to derive sequences; identifying recurrence relations until base case is true.
Example of linear recurrence equations : Recurrence Relations
Fibonacci: Fn = Fn-1 + Fn-2
Discrete Mathematical questions are better asked in Mathematics StackExchange or the Computer Science StackExchange.
Resources:
https://mathworld.wolfram.com/RecurrenceEquation.html
https://www.tutorialspoint.com/discrete_mathematics/discrete_mathematics_recurrence_relation.htm
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?
True or False:
Any problem that can be solved using dynamic programming has a polynomial time worst case time complexity with respect to its input size.
Are there any DP solutions which are not polynomial?
Thank you.
There is a dynamic programming algorithm for the Knapsack problem for which the worst-case complexity is O(Wn) where W is the capacity of the knapsack and n is the number of items. Such a runtime bound is termed as pseudo polynomial (as a value which is encoded in the instance occurs) and cannot be considered as polynomial in the input size. So, short answer: false.
Furthermore, the original question is formulated a bit misleading; the runtime complexity refers to a specific algorithm, not the problem itself.
There are many. The above example is one. Another popular example is dynamic programming solution of Traveling Salesman problem which runs in O(n2^n) time. Note that a brute force solution of Traveling Salesman takes O(n!) time, compared to that a dynamic programming solution is better.