2 ms·
In your example, that is O(1). A computer can add two numbers in constant time. How could that be two steps? It is obviously only one operation. In general, yo
by ericn 15y ago
In your example, that is O(1). A computer can add two numbers in constant time. How could that be two steps? It is obviously only one operation.
In general, you can count steps as whatever you like. For instance, you could say it takes O(n) CPU operations or O(n^2) file seeks. But then people use the word "time" as a proxy for those. You'll hear "constant time" or "order-n time".
- orthebox 15y agoSo basically every computation counts as a step? But how about control structures? Like in Python: "for i in range(4)", how many steps are there?