Lec03_ComplexityBasic_Count_2

Lec03_ComplexityBasic_Count_2 - Topics Instruction count...

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

View Full Document Right Arrow Icon
Topics Instruction count for statements Methods Examples
Background image of page 1

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

View Full DocumentRight Arrow Icon
Deriving Instruction Counts Given a (non-recursive) algorithm expressed in pseudo code we explain how to: Assign counts to high level statements Describe methods for deriving an instruction count Compute counts for several examples
Background image of page 2
Counts for High Level Statements Assignment loop condition for loop for loop body for loop control while loop while loop control while loop body if Note: The counts we use are not accurate; The goal is to derive a correct growth function
Background image of page 3

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

View Full DocumentRight Arrow Icon
Assignment Statement 1. A= B*C-D/F Count 1 = 1 In reality? At least 4 Note: When numbers B, C, D, F are very large, algorithms that deal with large numbers will be used and the count will depend on the number of digits needed to store the large numbers.
Background image of page 4
Loop condition 1. Count 1 = 1 Note : if loop condition invokes functions, count of function must be used
Background image of page 5

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

View Full DocumentRight Arrow Icon
for loop body 1. for (i=0; i < n; i++) 2. A[i] = i Count 2 = 1 Count 1(2) = How many times are there for the condition check? i = 0 i < n A[i] = i i = i + 1 true false - = 1 0 2 Count n i
Background image of page 6
for loop control 1. for (i=0; i < n; i++) 2. <body> Count = number times loop condition is executed (assuming loop condition has a count of 1) i = 0 i < n Body of the loop i = i + 1 true false
Background image of page 7

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

View Full DocumentRight Arrow Icon
for loop control 1. for (i=0; i < n; i++) 2. <body> Count
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 01/04/2010.

Page1 / 28

Lec03_ComplexityBasic_Count_2 - Topics Instruction count...

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

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