algorithm analysis (time complexity)

12
Algorithm Analysis (Time complexity)

Upload: karleigh-walls

Post on 03-Jan-2016

44 views

Category:

Documents


2 download

DESCRIPTION

Algorithm Analysis (Time complexity). Software development cycle Four phases: Analysis Design Design an algorithm to solve the problem or sub- problem. Algorithm is s tep by step problem-solving process, and solution obtained in finite amount of time. Implementation - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Algorithm Analysis (Time complexity)

Algorithm Analysis (Time complexity)

Page 2: Algorithm Analysis (Time complexity)

Software development cycle

-Four phases:1. Analysis 2. Design

Design an algorithm to solve the problem or sub- problem. Algorithm is step by step problem-solving process, and solution obtained in finite amount of time.

3. Implementation4. Testing and Debugging

Page 3: Algorithm Analysis (Time complexity)
Page 4: Algorithm Analysis (Time complexity)
Page 5: Algorithm Analysis (Time complexity)
Page 6: Algorithm Analysis (Time complexity)
Page 7: Algorithm Analysis (Time complexity)

Algorithm Analysis: The Big-O Notation (cont’d.)

- By analyzing a particular algorithm, we usually count the number of Primitive Operations:

1. Assigning a value to a variable2.Calling a function3.Performing an arithmetic operation4.Comparing two values5.Returning from a function

Page 8: Algorithm Analysis (Time complexity)
Page 9: Algorithm Analysis (Time complexity)
Page 10: Algorithm Analysis (Time complexity)
Page 11: Algorithm Analysis (Time complexity)
Page 12: Algorithm Analysis (Time complexity)

The Big-O Notation (cont’d.)

- The following table shows each of the seven common functions used in algorithm analysis in order of growth rates.

Examples:

1- F(n) = 5n2 + 3n log n + 2n + 5We say the function F(n) is O(n2) or Big-O of n2

2- F(n)= 3 log n + 2 We say the function F(n) is O(log n) or Big-O of log n

3- F(n)= 2n + 100 log n We say the function F(n) is O(n) or Big-O of n

constant logarithm linear n-log-n quadratic cubic exponential

1 log n n n log n n2 n3 an, a>1