COMPILED CANVAS
DSA IN JAVA

Same answer. One takes 1 second. One takes 3 hours.

That difference is Big O

Tap to start →

O(1)

Constant time

73916

Reading arr[5] takes one step, whether the array has 10 items or 10 million.

1 of 4 · keep tapping →
O(n)

One loop

for (int x : arr) sum += x; // n steps

Checking every item once. Twice the data, twice the time.

2 of 4 · keep tapping →
O(n²)

Loop inside a loop

O(1)
O(log n)
O(n)
O(n²)

Comparing every pair. 1,000 items means about a million steps.

3 of 4 · keep tapping →
O(log n)

Halving

1,000,000 → 20 steps

Binary search cuts the range in half each step. A million items take about 20 steps.

4 of 4 · keep tapping →
⚠ MOST PEOPLE MISS THIS

The mistake

Counting exact steps. Big O drops constants: 3n + 5 is just O(n).

QUICK QUIZ

Can you get it?

Tap an answer. The full video explains why.

📸 SCREENSHOT THIS

Cheat sheet

  • O(1): one step
  • O(log n): halve each time
  • O(n): one loop
  • O(n log n): good sorting
  • O(n²): loop in a loop
COMPILED CANVAS

Want the full lesson?

▶ Watch the full videoPractice + free notes

Free DSA in Java course. Subscribe to Compiled Canvas on YouTube.

Watch the full video