specification and complexity - algorithm

12
Algorithm Specification and Complexity

Upload: bipul-roy-bpl

Post on 26-Jan-2017

341 views

Category:

Software


4 download

TRANSCRIPT

Page 1: Specification and complexity - algorithm

Algorithm Specification and Complexity

Page 2: Specification and complexity - algorithm

Algorithm Criteria Every Algorithm must have satisfied following

Criteria:

05/01/23 2

Page 3: Specification and complexity - algorithm

Algorithm Specification

05/01/23 3

Page 4: Specification and complexity - algorithm

Algorithm Specification (Cont.)

05/01/23 4

Page 5: Specification and complexity - algorithm

Algorithm Specification (Cont.)

05/01/23 5

Page 6: Specification and complexity - algorithm

Algorithm Specification (Cont.)

05/01/23 6

Page 7: Specification and complexity - algorithm

Algorithm Time ComplexityAsymptotic Notations

, O,

05/01/23 7

(Theta) (Average Case)

(Big-oh) (Worst Case)(Upper Bound)

(Omega) (Best case)(Lower Bound)

Page 8: Specification and complexity - algorithm

Algorithm Time Complexity (Cont.)

05/01/23 8

Example: f(n) = 3n2 + 17

(1), (n), (n2) lower bounds

O(n2), O(n3), ... upper bounds

(n2) exact bound

Page 9: Specification and complexity - algorithm

Algorithm Time Complexity (Cont.)

05/01/23 9

Examples (For Practices):

3n+2=O(n) /* 3n+24n for n2 */

3n+3=O(n) /* 3n+34n for n3 */

100n+6=O(n) /* 100n+6101n for n10 */

10n2+4n+2=O(n2) /* 10n2+4n+211n2 for n5 */

6*2n+n2=O(2n) /* 6*2n+n2 7*2n for n4 */

Page 10: Specification and complexity - algorithm

Algorithm Time Complexity (Cont.)

05/01/23 10

Relations Between , , O:

Theorem : For any two functions g(n) and f(n), f(n) = (g(n)) if

f(n) = O(g(n)) and f(n) = (g(n)).

I.e., (g(n)) = O(g(n)) (g(n))

In practice, asymptotically tight bounds are obtained from asymptotic upper and lower bounds.

Page 11: Specification and complexity - algorithm

Algorithm Space Complexity S(P)=C+SP(I)

05/01/23 11

Fixed Space Requirements (C)Independent of the characteristics of the inputs and outputs instruction space space for simple variables, fixed-size structured variable,

constants Variable Space Requirements (SP(I))

depend on the instance characteristic I number, size, values of inputs and outputs associated with

I recursive stack space, formal parameters, local variables,

return address

Page 12: Specification and complexity - algorithm

Any Questions?????

Thanks To Everybody

05/01/23 12