0
GE(A[0..n-1,0..n])
// Input an n × (n + 1) matrix A[0 . . n − 1, 0 . . n] of real numbers
for i = 0 to n − 2
  for j = i + 1 to n − 1
    for k = i to n
      A[j, k] = A[j, k] − A[i, k] ∗ A[j, i]/A[i, i]

How to compute for its running time formally?

Bartłomiej Semańczyk
  • 52,820
  • 43
  • 206
  • 318
Gelo
  • 43
  • 1
  • 5
  • [`System.nanoTime()`](http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#nanoTime())? – Arc676 Nov 29 '15 at 09:57
  • Possible duplicate of [How do I measure time elapsed in Java?](http://stackoverflow.com/questions/1770010/how-do-i-measure-time-elapsed-in-java) – xaviert Nov 29 '15 at 10:06
  • whats the question ? and the problem ? – guillaume girod-vitouchkina Nov 29 '15 at 10:07
  • I'm sorry, okay to be more specific how to compute the running time of that algorithm? and I think there is an inefficiency in the algorithm but i'm not sure, what do you guys think? thanks in advance – Gelo Nov 29 '15 at 13:32
  • btw by running time i mean the time complexity of the algorithm. thanks again – Gelo Nov 29 '15 at 13:47

2 Answers2

0
long begining=System.currentTimeMillis();

 for (int i = 0, i<= n − 2; i++)
    for (j = i + 1; j<= n − 1; j++)
        for (k = i; k<= n; k++)
            A[j][k] = A[j][k] − A[i][k] ∗ A[j][i]/A[i][i];

long ending=System.currentTimeMillis();

long last_time=ending-begining; // Duration in milliseconds
0

It would be more helpful if you were more specific in your question. If you want to calculate the running time using a language function for a particular input,you could use System.nanoTime().

But if you wanted an asymptotic running time,it would be O(n^3) where n is the input size.

getsuga
  • 117
  • 10
  • I'm sorry, okay to be more specific how to compute the running time of that algorithm? and I think there is an inefficiency in the algorithm but i'm not sure, what do you guys think? thanks in advance ! – Gelo Nov 29 '15 at 13:35
  • btw by running time i mean the time complexity of the algorithm. thanks again – Gelo Nov 29 '15 at 13:47