





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 analysis of algorithms, focusing on statement analysis and the identification of critical sections and their impact on overall efficiency. It covers the characteristics of critical sections, the analysis of consecutive statements, if/else statements, for loops, and nested for loops. The document also includes general rules for analyzing algorithms.
Typology: Slides
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Statement Analysis – Critical Section
Statement Analysis - Sequence Consecutive statements
Block #
Block #
t 1
t 2
t 1 +t 2 = max(t 1 ,t 2 )
Statement Analysis - If
If/Else:
if cond then
S
else
S2; Block #1 t 1 Block #2 t 2 Max(t 1 ,t2)
Statement Analysis – Nested For
Nested For-Loops
running time of the statement multiplied by product of the sizes of all the for-loops
e.g. for (i =0; i < n; i++)
for (j = 0, sum = a[0]; j <= i ; j++)
sum += a[j]; printf("sum for subarray - through %d is %d\n", i, sum);
2
1
1 1 1
n
i
n
i
i
j
n
i
=
= = =