Time Complexity

What will be the time a program with time complexity O(2500000) will take to run ???

A loop that goes from 1 to 10^9 takes around 1 second in C/C++ (without performing any I/O)

25 x 10^5 operations will take less than 1 second, if you are not performing I/O.

Try writing small programs with different ranges, which perform various operations that are generally used to get a fair idea about how much time each code takes to run on your machine.

Specifically, the time taken depends on the number of cycles taken to perform a certain operation. Cache-misses, floating point calculations, etc result in a higher execution time.

1 Like