This question evaluates understanding of streaming data structures, sliding-window aggregation, and the time/space trade-offs involved in maintaining running statistics over recent inputs, testing algorithmic efficiency and numerical handling skills.
Design a data structure to compute the moving average over the last N values from a stream.
N
.
x
(integers or floats).
min(N, count_so_far)
values.
If N = 3 and the stream is 1, 10, 3, 5: