I know, for example, that:
for(int counter = 0; counter <= array.length-1; counter++)
{
for(int counter2 = 0; counter2 <= array.length-1; counter2++)
{
...
Results in an n? complexity (with n the amount of elements in the array), because we're having a double loop here.
While that is correct, do you really know how to calculate it?
The running time of that alone is O(n<sup>2</sup>), are you aware that OMEGA(n<sup>2</sup>) for that algorithm as well? It's also the average case.
Double looping doesn't guarentee quadratic or exponential time.
There's a set of rules, actually for this. (you should also use psuedo code so programming symantecs don't get in the way)
c1 n for counter <- 1 to length[A]
c2 n + SUM<sup>n</sup>[size=10]counter = 1[/size]t[size=10]counter[/size] do for counter2 <- 1 to length[A]
T(n) = c1 * n + c2 * (n + SUM<sup>n</sup>
counter = 1t
counter)
The summation is an arithmetic series
> c (n + n + (n(n + 1))/2)
> T(n) = (n<sup>2</sup> + 5n)/2
Since n<sup>2</sup> dominates the function, that is the running time. You can be more specific using that equation with a size n, but, it's in like microseconds, so it's very negligable.
So, the worst case is O(n<sup>2</sup>).
If you want to calculate the best case, you just use the best case cost. In this situation, the second loop is going through all elements (n) no matter what, so it's the same. Obviously, if the worst case and best case are the same, then the average case is the same also.
It really comes down to knowing what series to use when.
To get the running time of a recursive algorithm there are some methods to go about that. One of which is the master method, which is very simple to use. But, the recurrence needs to be in a specific form for you to use it. There's also a tree method (can't remember the name right now). But, you'd start seeing that more times than not with recursive algorithms (as opposed to looping inside a loop) you get logrithmic time rather than exponential!
Edit: Apparently, omega and summation ascii characters are not useable here. Lame.
Blame it on Microsoft, God does.