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.

MediumTechnical
82 practiced

Explain the Quickselect algorithm for finding the k-th smallest (or largest) element in an unsorted array. State its average-case and worst-case time complexity, and explain how the median-of-medians pivot-selection strategy guarantees O(n) worst-case time at the cost of a larger constant factor.

MediumTechnical
52 practiced

Compare the time complexity of Dijkstra's algorithm under different priority-queue implementations (array, binary heap, Fibonacci heap), and explain when you would reach for A* instead, including the role admissible and consistent heuristics play in guaranteeing A* still finds the optimal path while exploring fewer nodes.

EasyTechnical
83 practiced

Compare memoization (top-down) and tabulation (bottom-up) as two ways of implementing the same dynamic-programming solution. Discuss differences in time and space usage, recursion-depth risk, and ease of implementation, and give an example (like naive versus memoized Fibonacci) showing how memoization removes exponential recomputation to reach O(n).

MediumTechnical
53 practiced

Compare dynamic programming and greedy strategies using an example where greedy provably fails but DP succeeds (for example, coin change with a non-canonical coin system, or weighted interval scheduling versus a naive earliest-finish-time greedy). Explain, in general terms, what property a problem needs (optimal substructure without the greedy-choice property) for DP to be necessary rather than greedy sufficing.

HardTechnical
52 practiced

You are given the recurrence T(n) = 2T(n/2) + n/log(n), with T(1) = O(1). The Master Theorem's polynomial-gap requirement for case 3 is not satisfied here (n/log(n) is not polynomially larger than n^{log_2 2} = n), so a direct case lookup fails. Derive a tight bound for T(n) using the recursion-tree method instead, and explain why the result differs from what you would get by naively rounding to case 2.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.