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?
- 1The complexity silently becomes O(n³)
- ✓Correct answer: Garbage collection pressure that Big O doesn't show
- 3The engine refuses to run loops with allocations
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.