InterviewStack.io LogoInterviewStack.io

Time and Space Complexity Analysis Questions

Reasoning about algorithmic efficiency: Big-O/Theta/Omega notation, amortized analysis, recurrence solving, and the time-versus-space trade-off. Covers deriving bounds from code, comparing candidate approaches, and communicating complexity clearly under interview pressure. The analytical layer applied across every algorithm topic.

HardTechnical
47 practiced

A classic DP solution (for example edit distance / Levenshtein distance) uses O(nm) time and O(nm) space. Show how to reduce the space to O(min(n,m)) using a rolling array, demonstrate why correctness is preserved, and explain what you lose (the ability to reconstruct the full solution path) by making this trade.

HardTechnical
41 practiced

Compare a B-tree index and an LSM-tree (log-structured merge-tree) as the storage engine for a database, in terms of write amplification, read amplification, and space amplification. When would you reach for each, and why do write-heavy workloads tend to favor LSM-trees despite their read-path being more complex?

MediumTechnical
39 practiced

Compare the practical implications of an O(n log n) algorithm against an O(n) algorithm. Give a concrete example where the 'worse' asymptotic complexity actually wins in practice due to constant factors, cache behavior, or implementation simplicity, and explain how you would decide between two implementations - one O(n log n) with low constant factors, the other O(n) but with high memory churn and poor cache locality.

MediumTechnical
41 practiced

Compare full-batch gradient descent, mini-batch SGD, and pure SGD (batch size 1) on computational cost per epoch, memory overhead, and how batch size affects gradient-estimate variance and hardware (GPU) throughput. Why does throughput typically plateau past a certain batch size even though the asymptotic per-step compute keeps scaling?

HardTechnical
51 practiced

You must schedule a set of tasks (test-suite jobs, or a rolling deployment) across N parallel workers, respecting a dependency DAG and per-task duration estimates, to minimize total wall-clock time. This is a variant of an NP-hard scheduling problem. Explain why exact optimal scheduling is intractable at scale, and describe a practical heuristic (e.g. longest-processing-time-first, critical-path-first) along with the complexity of computing it and how close it gets to optimal.

Unlock Full Question Bank

Get access to all Time and Space Complexity Analysis interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.