3 ms·
This is O(n) because you're still doing the i < size comparison, even though you've moved it out of the for loop.
by fragmede 3y ago
This is O(n) because you're still doing the i < size comparison, even though you've moved it out of the for loop.
- markisus 3y agoFor almost all n (size), the function runs for MAX_SIZE steps, since almost all numbers are greater than MAX_SIZE. And it never runs for more than MAX_SIZE steps.