Review 1 Merge Sort Merge Sort Algorithm Time Complexity Best case Average case Worst case Examples.
Algorithm Analysis (Time complexity)
-
Upload
karleigh-walls -
Category
Documents
-
view
49 -
download
2
description
Transcript of Algorithm Analysis (Time complexity)
![Page 1: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/1.jpg)
Algorithm Analysis (Time complexity)
![Page 2: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/2.jpg)
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)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/3.jpg)
![Page 4: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/4.jpg)
![Page 5: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/5.jpg)
![Page 6: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/6.jpg)
![Page 7: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/7.jpg)
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)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/8.jpg)
![Page 9: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/9.jpg)
![Page 10: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/10.jpg)
![Page 11: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/11.jpg)
![Page 12: Algorithm Analysis (Time complexity)](https://reader035.fdocuments.net/reader035/viewer/2022062321/568134e7550346895d9c1df7/html5/thumbnails/12.jpg)
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