{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 7 Notes

# This version has run me m m versus 2m in computer

This preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: end! MyPi = pBest/qBest;! ! M versus 2M •  We can replace the inner loop with code that checks q- and q+ individually (this what was displayed in previous lecture) •  However, even without an explicit inner loop both values must be checked •  So, even in this case the run ,me is 2M •  In HW 3 you will discover a version that checks only one q for each p. This version has run ,me M M versus 2M •  In Computer Science run ,mes are reported in terms of bounds on the “order” (complexity) of M •  In this case constants are ignored, so M and 2M are both viewed as having run ,me complexity O(M) •  This is because as M grows, order dominates Quiz Time What is run ,me? •  Previously we had to check M p’s for each q •  Now we have to only check 2 p’s for each q •  There are M q’s A) M^2/2 B) M C) 2M D) S,ll M^2 M versus 2M •  In scien,ﬁc computa,on the constants and sizes of M o_en ma`er –  2M takes twice as long as M to compute –  1000M > 4M^2 for M < 250 •  So when we look at run ,me, we include the constants, par,cularly when reasoning a...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online