12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

74 Chap. 3 <strong>Algorithm</strong> <strong>Analysis</strong>because n grows faster than 2 log n. Thus, n 2 is in Ω(2n log n).3.5 Calculating the Running Time for a ProgramThis section presents the analysis for several simple code fragments.Example 3.9 We begin with an analysis of a simple assignment statement<strong>to</strong> an integer variable.a = b;Because the assignment statement takes constant time, it is Θ(1).Example 3.10 Consider a simple for loop.sum = 0;for (i=1; i

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

Saved successfully!

Ooh no, something went wrong!