1 2 3 4 5 6 7 8 9 |
|
The C++ code given above runs in .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The first for-loop runs 101-times which implies that it is O ( 1 0 1 ) which is equivalent to O ( 1 ) . Same is the case with the second for-loop and: O ( 1 ) + O ( 1 ) = O ( 1 ) Therefore, we say that the code runs in O ( 1 )
Note: Unless a loop runs n times for any non-negative integer n , it remains O ( 1 )