Design a class MovingAverage that supports a constructor MovingAverage(k) and a method next(val) returning the average of the last k values from a data stream (or all seen values if fewer than k). Achieve O(
amortized time per call and O(k) space. Explain your data structures, how you handle precision/overflow, and how you would test edge cases.