5. Standard algorithm
for i ←1 to n
do for j←1 to n
do cij←0
for k←1 to n
do cij←cij+ aik⋅bkj
N
C i, j a i ,k bk , j
k 1
N N N
3 3
Thus T ( N ) c cN O(N )
i1 j1k 1
6. Divide-and-Conquer
Divide-and conquer is a general algorithm design
paradigm:
Divide: divide the input data S in two or more disjoint
subsets S1, S2, …
Recur: solve the sub problems recursively
Conquer: combine the solutions for S1, S2, …, into a
solution for S
The base case for the recursion are sub problems of
constant size
Analysis can be done using recurrence equations
15. Analysis of Strassen's
T(n) = 7T(n/2) + Θ(n2)
nlogba= nlog27≈n2.81
⇒CASE1⇒T(n) = Θ(nlg7).
The number2.81may not seem much smaller than 3, but
because the difference is in the exponent, the impact on
running time is significant. In fact, Strassen’s algorithm
beats the ordinary algorithm on today’s machines for
n≥32or so.
Best to date (of theoretical interest only): Θ(n2.376…)