11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Sec. 3.1 Introduction 57n! 2 n2n 25n log n14001200100020n80060010n40020000 10 20 30 40 50400n!2 n2n 230020n2005n log n10010n00 5 10 15Input size nFigure 3.1 Two views of a graph illustr<strong>at</strong>ing the growth r<strong>at</strong>es for six equ<strong>at</strong>ions.The bottom view shows in detail the lower-left portion of the top view. The horizontalaxis represents input size. The vertical axis can represent time, space, orany other measure of cost.oper<strong>at</strong>ion for variable sum. We can assume th<strong>at</strong> incrementing takes constanttime; call this time c 2 . (We can ignore the time required to initialize sum,<strong>and</strong> to increment the loop counters i <strong>and</strong> j. In practice, these costs cansafely be bundled into time c 2 .) The total number of increment oper<strong>at</strong>ionsis n 2 . Thus, we say th<strong>at</strong> the running time is T(n) = c 2 n 2 .

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!