Specification and complexity - algorithm

bipulroybpl 3,257 views 12 slides Jan 04, 2016
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

Specification and complexity - algorithm


Slide Content

Algorithm Specification
and Complexity

Algorithm Criteria
Every Algorithm must have satisfied following
Criteria:
01/04/16 2

Algorithm Specification
01/04/16 3

Algorithm Specification (Cont.)
01/04/16 4

Algorithm Specification (Cont.)
01/04/16 5

Algorithm Specification (Cont.)
01/04/16 6

Algorithm Time Complexity
Asymptotic Notations
Q, O, W
01/04/16 7
 Q (Theta) (Average Case)
 O (Big-oh) (Worst Case)(Upper Bound)
 W (Omega) (Best case)(Lower Bound)

Algorithm Time Complexity
(Cont.)
01/04/16 8
Example: f(n) = 3n
2
+ 17
W(1), W(n), W(n
2
)  lower bounds
O(n
2
), O(n
3
), ...  upper bounds
Q(n
2
)  exact bound

Algorithm Time Complexity
(Cont.)
01/04/16 9
Examples (For Practices):
3n+2=O(n) /* 3n+2£4n for n³2 */
3n+3=O(n) /* 3n+3£4n for n³3 */
100n+6=O(n) /* 100n+6£101n for n³10 */
10n
2
+4n+2=O(n
2
) /* 10n
2
+4n+2£11n
2
for n³5 */
6*2
n
+n
2
=O(2
n
) /* 6*2
n
+n
2
£7*2
n
for n³4 */

Algorithm Time Complexity
(Cont.)
01/04/16 10
Relations Between Q, W, O:
Theorem : For any two functions g(n) and f(n),
f(n) = Q(g(n)) if
f(n) = O(g(n)) and f(n) = W(g(n)).
Theorem : For any two functions g(n) and f(n),
f(n) = Q(g(n)) if
f(n) = O(g(n)) and f(n) = W(g(n)).
I.e., Q(g(n)) = O(g(n)) Ç W(g(n))
In practice, asymptotically tight bounds are obtained from asymptotic upper and
lower bounds.

Algorithm Space Complexity
S(P)=C+S
P(I)
01/04/16 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 (S
P
(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

Any Questions?????
Thanks To Everybody
01/04/16 12