Skip to content

Counting steps

Read · 1 of 4

Speed is about growth

Java manages roughly 100 million simple steps per second. 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 HashMap or HashSet: about one step.