Download presentation

Presentation is loading. Please wait.

Published byRaymond Williamson Modified about 1 year ago

1

2
Complexity Theory

3
Complexity theory is a problem can be solved? Given: ◦ Limited resources: processor time and memory space

4
Algorithm

5
Definition: An algorithm is a finite step-by-step list of well- defined instructions for solving a particular problem. Algorithm complexity: is a key task in comparing the efficiency of algorithms. Two factors are considered: ◦ 1- the (running) timeTime Complexity ◦ 2- the space (usage)Space Complexity

6
Time Complexity: estimates the running time of the algorithm. ◦ Measured by the number of key step of the basic steps used by the algorithm. Basic Steps are: ◦ Arithmetic operations (+, -, *, /) ◦ Comparison operations (>, >=, <, <=, ==) ◦ Reading from a memory, file ◦ Writing to memory, file, (cin, fin)

7
Key step: The most costly step of the algorithm ◦ Takes most of the running time ◦ Other steps is much less or at most proportional to the time of the key step.

8
In worse-case analysis: ◦ We find the maximum value of the number of the key steps. In Average-case analysis: ◦ We find the average value of the number of the key steps.

9
Let f (n ) the complexity of an algorithm, i.e., ◦ # key operations ◦ For an instance of size n A computer processor has a speed of 1 MIP ◦ Million Instructions Per (MIP) second

10

11
Big Oh O() Notation is used ◦ To estimate the growth rate of f : N R + ◦ f O(g) ◦ There exist two positive integer k, n 0 : f(n) ≤ k*g(n), for all n ≥ n 0 f grows not fast than g f belongs to the complexity class O(g)

12
f(n) = 3 n+2= O(n) as 3 n +2 ≤ 4 n for all n ≥ 2. f(n) =100 n+6=O(n) as 100 n+6 ≤ 101 n for all n ≥ 6. f(n) =1000 n n - 6 = Ο(n 2 ) as 1000 n n - 6 ≤ 1001 n 2 for all n ≥ 100. f(n) = 6 2 n + n 2 = Ο (2 n ) as 6 2 n + n 2 ≤ 7 * 2 n for all n ≥ 4.

13
Find the class complexity of the following functions 1. f(n) = n n 2 - 8n + 6 2. f(n) = (6n 7 +4) / (n 2 +1) 3. f(n) = 2 n + 3n n 4

14

15
Common complexity classes O(1)< O(log n) < O(n)< O(n log n)< O(n 2 )

16
Dropping Coefficient ◦ f(n) = k * n c f O(n c ) ◦ f(n) = 10 n 4 f O(n 4 ) Dominant Term ◦ f(n) = n c +n c-1 +…+ n 2 +n+1 f O(n c ) ◦ f(n) = (n 8 + 1) / (n 3 + 2n 2 – 1) f O(n 5 )

17
Introduction to Algorithms

18
What is Algorithm ??

19
An algorithm : is a finite step-by-step list of well-defined instructions for solving a particular problem. Algorithm complexity is a key task in comparing the efficiency of algorithms. Two factors are considered: ◦ 1- the (running) timeTime Complexity ◦ 2- the space (usage)Space Complexity

20

21
Sorting Algorithms ◦ Bubble Sort ◦ Insertion Sort ◦ And many other algorithms (Quick Sort, Selection Sort, …. ) Searching Algorithms ◦ Linear search (sequential search) ◦ Binary search ◦ And many other algorithms (BFS, DFS, … ) And There are many and many algorithms used in this fields and other fields.

22
Sorting Algorithms Bubble sort

23
Insertion Sort

24

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google