Analysis 1.8

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

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

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

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

View Full Document
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
Last Updated: 10/01/12 5:45 AM CSE 2011 Prof. J. Elder - 38 -

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

### 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
Ask a homework question - tutors are online