









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of critical sections in algorithms and discusses the importance of analyzing their complexity. It covers the goal of algorithmic complexity analysis, the approach to finding critical sections, and examples of critical sections in various algorithms. The document also introduces recursive algorithms and the concept of asymptotic complexity categories.
Typology: Study notes
1 / 15
This page cannot be seen from the preview
Don't miss anything!










1
2
3
Analyzing Algorithms
Find asymptotic complexity of algorithm
Ignore less frequently executed parts of algorithm Find critical section of algorithm Determine how many times critical section is executed as function of problem size
4
Critical Section of Algorithm
Operation central to functioning of program Contained inside deeply nested loops Executed as often as any other part of algorithm
Loops Recursion
7
Critical Section Example 2
8
Critical Section Example 2
A โ once B โ n times
C โ n^2 times D โ once
9
Critical Section Example 3
10
Critical Section Example 3
A โ once B โ ยฝ n (n-1) times
13
Critical Section Example 5
14
Critical Section Example 5
A โ n^2 times B โ n^2 times
15
Critical Section Example 6
16
Critical Section Example 6
A โ log(n) times B โ 1 times
19
Recursive Algorithms
An algorithm that calls itself
Computation with no recursion
Recursive calls Combining recursive results
20
Recursive Algorithm Example
21
Asymptotic Complexity Categories
O(1) Constant Array access O(log(n)) Logarithmic Binary search O(n) Linear Largest element O(n log(n)) N log N Optimal sort O(n^2 ) Quadratic 2D Matrix addition O(n^3 ) Cubic 2D Matrix multiply O(nk) Polynomial Linear programming O(kn^ ) Exponential Integer programming
From smallest to largest
For size n, constant k > 1
22
Comparing Complexity
f(n), g(n)
As problem size n increases
If 0, g() is larger If constant, then same complexity
lim nโ โ
25
2D Matrix Multiplication Example
ฮฉ(n^2 ) Required to examine 2D matrix
O(n^3 ) Basic algorithm O(n2.807^ ) Strassenโs algorithm (1969) O(n2.376^ ) Coppersmith & Winograd (1987)
Since upper & lower bounds do not match
ร (^) =
26
Additional Complexity Categories
NP Nondeterministic polynomial time (NP) PSPACE Polynomial space EXPSPACE Exponential space Decidable Can be solved by finite algorithm Undecidable Not solvable by finite algorithm
Quadratic algorithms usually too slow for large data Use fast heuristics to provide non-optimal solutions
27
NP Time Algorithm
If make correct guesses on how to proceed
Boolean satisfiability Traveling salesman problem (TLP) Bin packing
Most efficient trip routes Most efficient schedule for employees Most efficient usage of resources
28
NP Time Algorithm
Can be solved with exponential time Not proven to require exponential time Currently solve using heuristics
Representative of all NP problems Solution can be used to solve any NP problem Examples Boolean satisfiability Traveling salesman