0

What is the order of growth of time complexity of this method?

I'm learning java and I came across this term and simply still dont understand the concept. So what is time complexity and how do a calculate it? https://code.sololearn.com/c345RgHQpYit/?ref=app

25th Jan 2019, 6:43 PM
mya
mya - avatar
5 Antworten
+ 2
So you know what time complexity is and want to know the time complexity of your code? I'd say O(n^2) because the whole list of numbers has to be iterated over with one nested loop, so there are length * length steps. https://en.m.wikipedia.org/wiki/Time_complexity
25th Jan 2019, 7:25 PM
Anna
Anna - avatar
0
I'm not sure but I think time complexity means the time for performing an action (for instance sorting an array).
25th Jan 2019, 6:48 PM
Théophile
Théophile - avatar
0
Théophile yeah I know that part. Just dont know how to calculate it
25th Jan 2019, 6:54 PM
mya
mya - avatar
0
Just store in a variable a the actual time at the beginning of your program. Then, at the end, take again the actual time and subtract it the number store in variable a
25th Jan 2019, 7:03 PM
Théophile
Théophile - avatar
0
Function to get actual time, in millisecond, is System.currentTimeMillis()
25th Jan 2019, 7:10 PM
Théophile
Théophile - avatar