Big O notation using the recursion method [duplicate] - algorithm

This question already has answers here:
Big O of Recursive Methods
(2 answers)
Closed 8 years ago.
How to find the Big O for the following recursive function using the recursive method:
T(n)=(n-1)T(n-1)+(n-1)T(n-2)

Anyway, I tried to solve this case using the classic recursive relation methodology.
It's all about observing if a pattern exists:
Very expensive algorithm (Enemies of computer science are factorial and exponential orders of growth).

Related

Can't define runtime for 2 functions [duplicate]

This question already has answers here:
How can I find the time complexity of an algorithm?
(10 answers)
Big O, how do you calculate/approximate it?
(24 answers)
Closed 5 years ago.
Hello, I have 2 functions in the image. And the question is about getting their runtime.
The answer for EX4 function is O(n^2) and EX5 is O(n^4).
I don't get this.
Question for EX4:
we have inner loop that starts with j=0 to i. From my perspective, this is equivalent to "1+2+...+n", so is "n(n+1)/2", therefore, O(n^2) for inner loop only.
However, we also know that outer loop runs from i=0 to n, which is O(n). So the answer I thought for EX4 was actually "O(n) * O(n^2) = O(n^3)". But the real answer says O(n^2). Why is that?
Question for EX5:
Similarly, I thought it is "n*(n+1)/2 = O(n^2)" for inner loop and also "n*n=O(n^2)" for outer loop, so the whole runtime become O(n^2) * O(n^2) = O(n^4), which is same as real answer of this question. But if I justify this in this way, then my solution to EX4 doesn't make sense. Why is it O(n^4) specifically?

Does append() in Go run on amortized constant time? [duplicate]

This question already has an answer here:
Big O of append in Golang
(1 answer)
Closed 6 years ago.
Java's ArrayList add method runs in amortized constant time. Same for vector's push_back in C++.
So does append() in Go also run on amortized constant time?
see https://blog.golang.org/slices
The answer should be 'yes' as you expect

What is the difference between O(n) and O(n) with tilde [duplicate]

This question already has answers here:
What does Õ (omicron tilde) mean in complexity Õ(n) vs O(n) [closed]
(2 answers)
Closed 7 years ago.
I have come across saying that O(n) with tilde hides polylog(n)factors and an additive polylog(n) term.
What exactly these terms mean ?
This would probably mean that there is c > 0 such that f(n) <= n (log n)^c.
Note however that definitions of these kind of things may fluctuate.
Duplicate with What does Õ (omega tilde) mean in complexity Õ(n) vs O(n)

How are T(n) and Theta(f(n)) different? [duplicate]

This question already has answers here:
What is the difference between Θ(n) and O(n)?
(9 answers)
What is a plain English explanation of "Big O" notation?
(43 answers)
Closed 8 years ago.
When people explain Theta notation, they just start talking about a function T(n) without explaining what it is. Is it just a given function?
Why is it Theta(f(n)) instead of Theta(n)? Where did the f(n) come from? f(n) is usually a given function, then what is T(n)? Are they both? This is also not commonly explained.
All the explanations I find are all explained mathematically, but with consistent failure properly define things, and instead just start talking about things out of the blue.
Thanks,
- A confused student

log base 2 equals log base 3 when analyzing time complexity? [duplicate]

This question already has answers here:
Is Big O(logn) log base e?
(7 answers)
Closed 8 years ago.
Most solutions to Exercise 4.4.6 of Intro. to Algorithms 3rd edition say,
n*log3(n) = Big omega of (n*lg(n)).
Dose it mean log3(n) is equivalent to log2(n) when we are discussing time complexity of algorithms?
Thanks
As far as big-Oh notation is concerned, the base of the logarithms doesn't make any real difference, because of this important property, called Change of Base.
According to this property, changing the base of the logarithm, in terms of big-oh notation, only affects the complexity by a constant factor.
So, yes. In terms of big-Oh notation, log3(n) is equivalent to log2(n).

Resources