Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upper bound vs lower bound for worst case running time of an algorithm

I am learning about analysis of algorithms. I understand the concept of the worst case running time of an algorithm.

However, what are upper and lower bounds on the worst case running time of an algorithm?

What can be an example where an upper bound for the worst case running time of an algorithm is different from the lower bound for the worst case running time of the same algorithm?

like image 421
Amulya Khare Avatar asked Oct 02 '11 20:10

Amulya Khare


People also ask

Is upper or lower bound of the running time of an algorithm synonymous to its worst or best case running time?

Yes, it can mean worst case synonymous with upper bound and best case synonymous with lower bound. Worst-case performance is the most used in algorithm analysis. In the worst-case analysis, we guarantee an upper bound on the running time of an algorithm which is good information.

What is the difference between an upper bound and lower bound for the runtime of an algorithm?

Proving an upper bound means you have proven that the algorithm will use no more than some limit on a resource. Proving a lower bound means you have proven that the algorithm will use no less than some limit on a resource. "Resource" in this context could be time, memory, bandwidth, or something else.

Is upper bound same as worst case?

The upper bound is not the same as the worst case. We don't want to tie best and worst cases to input size.

What is the time complexity of algorithm in worst case?

It gives an upper bound on the resources required by the algorithm. In the case of running time, the worst-case time complexity indicates the longest running time performed by an algorithm given any input of size n, and thus guarantees that the algorithm will finish in the indicated period of time.


1 Answers

For a function f(n), g(n) is an upper bound (big O) if for "big enough n", f(n)<=c*g(n), for a constant c. [g dominates f]
g(n) is lower bound (big Omega) if for "big enough n", f(n) >= c*g(n), for a constant c. [f dominates g]

If g(n) is both upper bound and lower bound of f(n) [with different c's], we say g(n) is a tight bound for f(n) [Big theta]

Use example for upper bound instead of tight one: Sometimes, it is hard to find tight bound, such as the fibonacci recursive algorithm. So we find an easy upper bound of O(2^n) easily. more info is found in answers in this post.

How does it related to worst/base/... cases? (as requested by comments):

Worst case/average case (or any other case) affects what the complexity function is, but big-O, big-Omega, and big-Theta can be applied to each of these cases.

For example, a HashTable insert is Θ(1) average case insertion, and Θ(n) worst case insertion. It is also O(n) average case insertion (bound is not tight), and Ω(1) worst case insertion.

like image 143
amit Avatar answered Sep 29 '22 03:09

amit