Professional Documents
Culture Documents
Big-O Notations
Cho-Jui Hsieh
UC Davis
From Wikipedia:
The time complexity of an algorithm quantifies the amount of time taken
by an algorithm to run as a function of the length of the input
The time complexity of an algorithm is commonly expressed using big O
notation, which excludes coefficients and lower order terms.
Time Complexity
From Wikipedia:
The time complexity of an algorithm quantifies the amount of time taken
by an algorithm to run as a function of the length of the input
The time complexity of an algorithm is commonly expressed using big O
notation, which excludes coefficients and lower order terms.
Although time complexity is a good indication of efficiency, in practical
numerical computation sometimes constants are important:
For example, time for running 1 billion operations:
exp: 30.19 secs
*: 1.84 secs
/: 7.31 secs
+: 1.77 secs
In this course we will ignore these constants
Big-O
Definition of O():
Let f and g be two functions, we write
Definition of O():
Let f and g be two functions, we write
Definition of ():
Let f and g be two functions, we write
f (x) = (g (x)) as x
Definition of ():
Let f and g be two functions, we write
f (x) = (g (x)) as x
Definition of ():
Let f and g be two functions, we write
f (x) = (g (x)) as x
Definition of ():
Let f and g be two functions, we write
f (x) = (g (x)) as x
If x, y Rm are dense:
x + y, x y, x T y: O(m) operations
If x, y Rm , x is dense and y is sparse:
x + y, x y, x T y: O(nnz(y)) operations
If x, y Rm and both of them are sparse:
x + y, x y, x T y: O(nnz(y) + nnz(x)) operations
Dense Matrix vs Sparse Matrix