Analysis 1.8 - Prefix Averages (Linear) The following...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Last Updated: 10/01/12 5:45 AM CSE 2011 Prof. J. Elder - 36 - Prefix Averages (Linear) The following algorithm computes prefix averages in linear time by keeping a running sum Algorithm prefixAverages2 ( X, n ) Input array X of n integers Output array A of prefix averages of X #operations A new array of n integers n s 0 1 for i 0 to n ± 1 do n s s + X [ i ] n A [ i ] s / ( i + 1) n return A 1 Algorithm prefixAverages2 runs in O ( n ) time
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Last Updated: 10/01/12 5:45 AM CSE 2011 Prof. J. Elder - 37 - Relatives of Big-Oh Big-Omega f(n) is Ω (g(n)) if there is a constant c > 0 and an integer constant n 0 1 such that f(n) c•g(n) for n n 0 Big-Theta f(n) is Θ (g(n)) if there are constants c 1 > 0 and c 2 > 0 and an integer constant n 0 1 such that c 1 •g(n) f(n) c 2 •g(n) for n n 0
Background image of page 2
Last Updated: 10/01/12 5:45 AM CSE 2011 Prof. J. Elder - 38 -
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

Analysis 1.8 - Prefix Averages (Linear) The following...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online