DevToolsHub Free · Fast · 100% in your browser

Big-O Complexity Quiz

Read the code and pick its time complexity: O(1), O(log n), O(n), O(n log n), O(n²) or O(2ⁿ). Great practice for coding interviews.

Question1 / 18
Score0
Streak0
Best streak0

Time complexity of finding an item in a balanced BST?

while (node != null && node.Value != x)
    node = x < node.Value ? node.Left : node.Right;

About this Big-O notation quiz

Practice time complexity analysis for coding interviews. Each question shows a short code snippet and asks for its Big-O complexity, from O(1) and O(log n) to O(n log n), O(n²) and O(2ⁿ), with an explanation after every answer.

How to use the Big-O Complexity Quiz

  1. Read the code snippet.
  2. Pick its time complexity.
  3. Read the explanation and continue.

Example

for (i = 1; i < n; i *= 2)  →  O(log n)

Frequently asked questions

Why are constants dropped in Big-O?

Big-O describes growth as n becomes large, so O(2n) and O(n) grow the same way and are both written O(n).

What is the complexity of a hash map lookup?

O(1) on average, O(n) in the worst case when many keys collide.

Is my data safe?

Yes. The tool runs entirely in your browser using WebAssembly. Nothing you type or upload is sent to a server, logged or stored.

Is it free?

Yes, completely free with no sign-up, no limits and no watermarks. It also works offline once the page has loaded.

An unhandled error has occurred. Reload ✕