Skip to content
Get started

Additions in a naive moving average

You compute a 55-element moving average over an array of length 2020 the naive way - for each output window you re-sum all 55 of its elements from scratch. Counting only the additions performed (a sum of kk numbers costs k−1k-1 additions), how many additions does this take in total?

Show hints (2)+
  1. Number of windows =m−n+1=16= m - n + 1 = 16; each window-sum of 55 elements costs 44 additions.
  2. Total =16×4= 16 \times 4.

Answer

Reveal answer →

64

Create a free account to see the full worked solution and track your progress.

Interview format: Hedge Fund Quant, Prop Trading

Related questions