How is computational complexity determined?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
~Death~
Messages
45
Reaction score
0
like for any algorithm?

On wikipedia it lists for multiplication it's O(n^2)

but some of them have decimals like O(5/2n^2.2342) or something so how would you determine that?

Just use a computer and make a graph of input in bytes vs time in seconds and fit a curve to it?

Like I understand for eg the problem of determining if there's exists a subset of integers in another subset of integers such that they add to 0:

If the algorithm was to check each subset, if there's n integers then there's 2^n-1 subsets to check, but then youd have to add each one -so that would count as a step?

so there's 2^n+n-1 steps for an input of n ..does that mean its on the order of O(2^n) ?
 
Last edited:
Mathematics news on Phys.org
You might want to check out http://en.wikipedia.org/wiki/Big-o_notation first.

So yes, [itex]2^n+n-1\in\mathcal{O}(2^n)[/itex]. To determine this, you don't run the algorithm; you have to analyze (usually) the number of bit-operations it takes for your algorithm to terminate, given an input of n bits. Usually this number jumps around depending on the input, so we usually just look at the WORST case or the AVERAGE case.