0

I need to reverse a list in python3 using the function below:

def flip(arr):
   arr = arr[::-1]
   return arr

I would like to know what the runtime for this function is.

wawaloo_17
  • 157
  • 3
  • 10

1 Answers1

0

using timeit module

timeit.timeit(stmt='pass', setup='pass', timer=, number=1000000)

>>? def flip(arr):
        arr = arr[::-1]
        return arr

>>? import timeit
>>? timeit.timeit('__main__.flip(range(10000))', 'import __main__', number=1)
0.0005059589886400317
Skycc
  • 3,496
  • 1
  • 12
  • 18
  • 1
    What does the returned time indicate? How can you prove the time complexity with a single value? – wawaloo_17 Jul 13 '19 at 02:04
  • The return time is the runtime for the function in seconds. The time complexity is o(n). You can examine the runtime with variable size input list – Skycc Jul 13 '19 at 22:59