Algorithmic Complexity & Code-Level Optimization Questions

Reasoning about the time and space complexity of code and applying local optimizations that materially change performance. Covers Big-O and amortized analysis, performance modeling, data-structure selection, hot-loop and allocation reduction, hardware-aware work such as cache locality, vectorization and false sharing, knowing when an algorithmic change beats micro-optimization, and the measurement practice that grounds those calls: flame graphs, hardware counters, and microbenchmarks that survive warmup, noise and statistical scrutiny. Emphasizes performance-aware coding grounded in complexity and measurement rather than premature tuning, scoped to code you can change rather than production incident response or capacity planning.

HardTechnical
72 practiced

Estimate the additional energy consumption of running a computation that performs 1e9 CPU cycles on an ARM mobile core with energy cost ≈ 3e-11 joules per cycle. If the device battery is 3000 mAh at 3.7V, how much battery percentage would the computation consume? Show your calculations and assumptions.

MediumTechnical
101 practiced

Compare LRU and LFU cache eviction policies for a backend cache storing session objects. Analyze average-case complexity for access/update, explain how workloads like scans or one-off spikes affect hit-rate for each, and propose a hybrid strategy to mitigate weaknesses.

MediumTechnical
91 practiced

Implement quickselect in Python to find the kth largest element in an unsorted list. Your implementation should aim for average O(n) time and O(1) extra space (in-place). Specify behavior for invalid k and duplicate elements. Provide code and explain the average and worst-case complexity.

MediumTechnical
87 practiced

A C++ service processes millions of small structs per second in a tight loop. Explain the performance implications of array-of-structures (AoS) versus structure-of-arrays (SoA) on memory bandwidth, cache utilization, and vectorization. Give an example where SoA enables SIMD optimizations and explain why AoS might be slower.

HardTechnical
103 practiced

You ran an A/B microbenchmark with 50 latency samples for Server A (mean=20ms, sd=5ms) and 50 for Server B (mean=18ms, sd=6ms). Perform a two-sample t-test at α=0.05 to determine if Server B is significantly faster. Show calculations for the t-statistic, approximate degrees of freedom, and a 95% confidence interval for the mean difference. Finally, estimate the sample size required to detect a 1ms difference with power = 0.8 (assume pooled sd approx 5.5ms).

Unlock Full Question Bank

Get access to all 49 Algorithmic Complexity & Code-Level Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.