0

I'm learning how to find t(n) function in java, but this is very confusing and I need help. For example:

   for (int k=3; k<n; k++) {
   for (int i=2; i<10; i++)  {
      for (int j=n/2; j<n; j++)   {
            int a = k*i*j;
            System.out.println(a);
      }
   }
 }

Would the T(n) function be: T(n) = 3(4(n+1) +n)+3(3(not sure)+n)+ 4()+1

With

3(4(n+1) +n)

3= 3 steps for this line of code

4= representing k=3

N+1= representing k

+n= representing k++

and then:

3(3(not sure what goes here for i<10)+n)

firs 3= 3 steps

next 3= representing i=2

+n= representing i++

How does this work exactly?

and what would be the notation for the remaining lines?

user2985442
  • 1
  • 1
  • 1
  • possible duplicate of [How to find time complexity of an algorithm](http://stackoverflow.com/questions/11032015/how-to-find-time-complexity-of-an-algorithm) – Euphoric Nov 10 '14 at 07:07
  • How many times will the line `System.out.println(a)` run? That's your answer, I would guess. – Tony Nov 10 '14 at 07:07
  • I looked at that link before and I got a better understanding for it before I posted this question, that's why I tried to do this problem based on the examples on that page. I just wanted to see if I was doing this right. Plus I don't need the big O notation of this problem. Just the time complexity function. – user2985442 Nov 10 '14 at 07:33

0 Answers0