What this is for
You are solving an algorithm question and the input can get large. This tool tells you which running time is fast enough, so you do not try an answer that will be too slow.
Use it at the start, when you set a target. Skip it when the input is tiny, because then anything works.
As a rough guide, a computer does about 10^8 simple steps per second.
Try it
Type the largest value n can have. The row that fits is shown with the reason.
The table
This is the same data the tool uses. If the tool does not load, read your answer from here.
| Limit on n | Target running time |
|---|---|
| up to 12 | O(n!), permutations |
| up to 25 | O(2^n), subsets, bitmask |
| up to 500 | O(n^3) |
| up to 5,000 | O(n^2) |
| up to 10^6 | O(n log n) or O(n) |
| up to 10^8 | O(n): one simple pass, nothing heavier |
| more than 10^8 | O(log n) or O(1), usually a formula or a binary search |
For agents
Run it from the repository, with no browser:
node cli.mjs running-time '{"n": "10^5"}'
The result is JSON: ok, summary, and matches, a list of {id, label, detail}. Here id is the row it matched and detail says why. Accepted forms of the number: 100000, 100,000, 10^5, 1e5. A value that is not a number gives ok: false and no matches.
The logic is /tools/running-time/logic.mjs and the data is /tools/running-time/data.json. Every example in the data file is checked by npm test.
Related
- Problem Solving: the method this tool belongs to (step 2, set the target).