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 k1k-1 additions), how many additions does this take in total?

Show hints (2)+
  1. Number of windows =mn+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

Want the full step-by-step worked solution? It's part of Premium - along with a worked solution for every question in the bank.

Asked at: Multi-Strategy Quant, Mixed Quant & Coding

Related questions