LearnThatStack Ace your next interview
Computer Science Fundamentals
Big-O & Complexity Analysis.
Change topic Change
Practice · Questions

All questions

Showing of 53
Beginner 12
01

What is Big-O notation and what problem does it solve?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Big-O notation describes how an algorithm's work grows as its input gets larger. It ignores machine speed and focuses on the shape of that growth. This lets you compare two approaches without running either on a specific computer.

The problem it solves is fair comparison. A fast laptop can make a bad algorithm look quick on tiny inputs. Big-O strips away hardware and fixed setup, so you see which method wins once data gets big.

You use it to predict scaling. If a report takes one second on a thousand rows, Big-O tells you whether a million rows means minutes or days. That decides whether your design survives real traffic instead of collapsing under it.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What do O(1), O(n), O(log n), and O(n^2) mean in plain terms?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Each class names how the running time reacts when you double the input.

  • O(1) constant: the cost stays the same no matter the size. Reading one array slot by its index never gets slower.
  • O(n) linear: cost grows in step with size. Scanning n items takes twice as long when n doubles.
  • O(log n) logarithmic: doubling the input adds just one more step. Binary search on sorted data behaves this way.
  • O(n^2) quadratic: cost grows with the square. Comparing every pair quadruples when the list doubles.

The gaps between these decide real performance. At a million items, O(log n) is about twenty steps while O(n^2) is a trillion. That difference is why picking the right class matters more than any small code tweak.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What is the difference between best, average, and worst case complexity?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Best, average, and worst case describe one algorithm running on different inputs. Worst case is the slowest an input can make it. Best case is the luckiest input. Average case is what you expect over typical data.

Take searching an unsorted list for a value. Best case, it sits first, so O(1). Worst case, it sits last or is missing, so O(n). Average case lands around the middle, still O(n).

You usually plan around worst case because it bounds the pain. Best case is often useless for guarantees. Average case matters when you know the data behaves normally and rare slow inputs are acceptable in your system.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What is the difference between time complexity and space complexity?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Time complexity measures how many operations an algorithm performs. Space complexity measures how much extra memory it needs while running. Both grow with input size, but they answer different questions about cost.

Consider summing an array. You touch each element once, so time is O(n). You only keep one running total, so extra space is O(1). The two numbers move independently of each other.

They often trade against each other. A lookup table can make code faster while eating more memory. Knowing both matters because a program can be quick yet crash by exhausting RAM, or thrifty yet far too slow to use.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

How do you work out the time complexity of a simple loop?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Count how many times the loop body runs as the input grows. A loop that visits every one of n items runs n times. If each pass does a fixed amount of work, the loop is O(n).

for (let i = 0; i < n; i++) {
  total += arr[i]; // runs n times, O(1) each
}
// whole loop: O(n)

The loop bound is what matters, not the constant work inside. A loop from zero to n stays O(n) even if the body does ten small steps.

Look at what the counter depends on. If it runs a fixed number of times regardless of input, that part is O(1). A bound that grows differently, like stopping at the square root of n, changes the class.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

Why do we drop constants and lower-order terms in Big-O?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

We drop constants and lower-order terms because Big-O tracks growth shape, not exact operation counts. Multiplying by two or adding a fixed setup does not change how a curve bends as input explodes.

Say an algorithm does 3n + 100 steps. For small n the hundred dominates. But as n reaches millions, the 3n swamps it, and the factor three does not change that it grows linearly. So we call it O(n).

This keeps comparisons honest and hardware-free. A constant might just come from one machine being faster. By ignoring it, Big-O captures the property that survives across computers: which algorithm pulls ahead as the problem gets large.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

What are the common growth rates ordered from fastest to slowest?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Ordered from cheapest to most expensive as input grows, the common classes run like this:

  • O(1) constant: same cost always, like a hash lookup.
  • O(log n) logarithmic: binary search on sorted data.
  • O(n) linear: one scan through the data.
  • O(n log n) linearithmic: the best general sorting.
  • O(n^2) quadratic: comparing every pair.
  • O(2^n) exponential: trying every subset.
  • O(n!) factorial: trying every ordering.

"Fastest" here means it grows slowest, so it stays cheap at scale. The jumps are brutal. At a thousand items, linear is a thousand steps while quadratic is a million. Anything exponential or factorial becomes hopeless past small inputs, so spotting it early saves you from a program that never finishes.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

What is the difference between Big-O, Big-Theta, and Big-Omega notation?

Part of Pro
09

How do you find the time complexity of two nested loops?

Part of Pro
10

Why does repeatedly halving the input produce logarithmic time?

Part of Pro
11

What are the time complexities of the basic array operations?

Part of Pro
12

Why is hash table lookup usually O(1), and what makes it slower?

Part of Pro
Intermediate 20
13

When do you add complexities together and when do you multiply them?

Part of Pro
14

How do you derive the running time of a recursive function?

Part of Pro
15

What is the master theorem and when can you apply it?

Part of Pro
16

How does memoization change the complexity of recursive Fibonacci?

Part of Pro
17

What is amortized analysis and when does it apply?

Part of Pro
18

Why is appending to a dynamic array O(1) amortized despite resizing?

Part of Pro
19

What is the difference between amortized and average-case complexity?

Part of Pro
20

When should you describe complexity with two variables like O(n + m)?

Part of Pro
21

How does a linked list's complexity compare to an array's for common operations?

Part of Pro
22

When is a hash table a worse choice than a balanced tree?

Part of Pro
23

How does an unbalanced tree degrade a binary search tree's operation costs?

Part of Pro
24

What are the time complexities of the core heap operations, and why?

Part of Pro
25

Why is graph traversal O(V + E) rather than O(V^2)?

Part of Pro
26

Why does the base of a logarithm not matter in Big-O?

Part of Pro
27

Why do so many efficient algorithms land at O(n log n)?

Part of Pro
28

What is a space-time tradeoff, with a concrete example?

Part of Pro
29

Why does string concatenation inside a loop often cost O(n^2)?

Part of Pro
30

How do hidden costs of library functions distort your analysis?

Part of Pro
31

How do you use the input constraints in a problem to decide which complexity class is fast enough?

Part of Pro
32

What are the time and space complexities of the common sorting algorithms, and when does each one win?

Part of Pro
Expert 21
33

Why can an O(n) array scan beat an O(n) linked list in practice?

Part of Pro
34

When is an O(n^2) algorithm actually faster than an O(n log n) one?

Part of Pro
35

How can an excellent Big-O hide a constant factor that makes it unusable?

Part of Pro
36

Why is amortized O(1) not good enough for a latency-sensitive system?

Part of Pro
37

Why can crafted keys force a hash table to O(n), and how do randomized seeds help?

Part of Pro
38

How does the external-memory IO model change which algorithm wins?

Part of Pro
39

What is the space cost of deep recursion, and when does the stack overflow?

Part of Pro
40

How does converting recursion to iteration change space complexity?

Part of Pro
41

How do you keep a hash table resize from causing a latency spike?

Part of Pro
42

What does making a data structure thread-safe cost in complexity terms?

Part of Pro
43

How do you analyze an algorithm that processes a stream in constant space?

Part of Pro
44

When is it worth trading exact answers for space with a probabilistic structure?

Part of Pro
45

Why do cache misses often dominate runtime more than raw operation count?

Part of Pro
46

What changes in your analysis scaling from a million to a billion elements?

Part of Pro
47

How do you reason about complexity across a sharded, distributed system?

Part of Pro
48

How do you spot accidental exponential blowup in recursive branching?

Part of Pro
49

When does parallelism reduce complexity and when does it just add overhead?

Part of Pro
50

How do you empirically verify the constant factors that Big-O ignores?

Part of Pro
51

Why is the O(nW) knapsack dynamic program called pseudo-polynomial rather than polynomial?

Part of Pro
52

What does it mean for a problem to be NP-complete, and how is that different from an algorithm merely being slow?

Part of Pro
53

Why can no comparison-based sort beat O(n log n), and how do counting and radix sort get around that bound?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Big-O & Complexity Analysis? Send them this set.
Pro · $10/mo

46 of 53 Big-O & Complexity Analysis answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git