Algorithms and Data Structures · Senior · Question 73 of 75

An algorithm runs in O(n) but allocates a new array on every iteration of a hot loop. What's the likely real-world issue?

Explanation

Allocation and GC pauses add constant factors and latency spikes. Reusing buffers or typed arrays often gives large speedups without changing the asymptotic complexity.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 73

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz