2019-02-06 Basic Algorithms Lec4

Recursion

function Sums(S, A[1..n])
result = 0
for i from 1 to n
for j from i to n
if A[i]+A[j] = S
result = result + 1
return result

talk about runtime
can can not
predict how it scales predict actual runtime

Big-O and notation

Properties:

  1. ignore slow-growing things
  2. reason about relaative growth, e.g., and should be the same

Definition

We shall say that if there exist such that for all
For an algorithm with runtime , is it true that ?
No, it just says the algorithm is NOT WORSE THAN .

你可能感兴趣的:(2019-02-06 Basic Algorithms Lec4)