Skip to content

Counting steps

Read · 1 of 3

Speed is about growth

Python manages roughly 10 million simple steps per second (C++ about 10 times more). What matters is how the steps grow with the input size n.

One loop over n items: about n steps, O(n). A loop inside a loop: n × n, O(n²). Halving each time: O(log n). Looking something up in a set or dict: about one step.