Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a programmatic way or eclipse plugin to calculate big O notation for java method [closed]

Is there a programmatic way or eclipse plugin to calculate big-O notation for java method ?

like image 318
Amgad Hanafy Avatar asked Jul 17 '16 11:07

Amgad Hanafy


People also ask

How can we calculate complexity of a program in Java?

The time complexity of a loop is equal to the number of times the innermost statement is to be executed. On the first iteration of i=0, the inner loop executes 0 times. On the first iteration of i=1, the inner loop executes 1 times. On the first iteration of i=n-1, the inner loop executes n-1 times.

What is BIGO in Java?

Big O describes the set of all algorithms that run no worse than a certain speed (it's an upper bound) Conversely, Big Ω describes the set of all algorithms that run no better than a certain speed (it's a lower bound) Finally, Big Θ describes the set of all algorithms that run at a certain speed (it's like equality)

Which is used to measure the complexity using Big-O notation?

Which is used to measure the Time complexity of an algorithm Big O notation? Explanation: Big O notation describes limiting behaviour, and also gives upper bound on growth rate of a function. Explanation: The growth rate of that function will be constant.

What is Big O notation Java?

This Big O Notation Java example consists of a Maven project which shows time and space complexity analysis via these notations. Do you want to know how to develop your skillset to become a Java Rockstar?

What is the quickest way to calculate time in Java?

Constant time algorithms are (asymptotically) the quickest. Logarithmic time is the next quickest. Unfortunately, they're a bit trickier to imagine. One common example of a logarithmic time algorithm is the binary search algorithm. To see how to implement binary search in Java, click here.

What is the difference between Big O and big Ω?

Big O describes the set of all algorithms that run no worse than a certain speed (it's an upper bound) Conversely, Big Ω describes the set of all algorithms that run no better than a certain speed (it's a lower bound) Finally, Big Θ describes the set of all algorithms that run at a certain speed (it's like equality)

What is Big O in machine learning?

Big O is what is known as an asymptotic function. All this means, is that it concerns itself with the performance of an algorithm at the limit – i.e. – when lots of input is thrown at it. Big O doesn't care about how well your algorithm does with inputs of small size.


1 Answers

No, there isn't such plugin, and if it was, it would be a mere approximation. Namely, even determining whether the program will finish running or not is intractable - see Halting problem.

Now, about the possible approximation. Let's say you have a plugin that tests your program with a small dataset (e.g. N = 1000) and a medium dataset (e.g. N = 10000). If your program runs 10 times longer with a medium dataset compared to a small dataset, plugin should conclude that your program is O(N), right? Not quite. What about best/average/worst case? For example, quicksort's worst case is O(N^2), but it is generally considered as O(N*logN) sorting algorithm. Therefore, if the plugin hits the special input, it will give a wrong result. What about constants? The program whose running time is O(N + k*logN) is considered O(N), but if a constant k is large enough compared to N, plugin would not be able to reach this conclusion, etc.

Regarding your comment:

If anybody tried codility challenges they are evaluation your solution against performance using big O notation , and I'm sure that they are not calculation it manually, that's why I'm asking this question.

Authors of Codility challenges have solutions of their problems with a well-known time complexity (they analyzed it manually). When they measure the running time of your solution for various input and compare it with a running time of their solutions for the same input, they can automatically determine the time complexity of your program (of course, taking into account the programming language you have chosen and certain deviations of the measured time).

like image 63
Miljen Mikic Avatar answered Sep 19 '22 20:09

Miljen Mikic