Download CSE 3358 Note Set 1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CSE 3358
NOTE SET 3
Data Structures and Algorithms
Objectives



Properties of Big-O
Standard Complexities
Finding Complexity from an algorithm
Big – O: Transitivity
If f(n) is O(g(n)) and g(n) is O(h(n)),
then f(n) is O(h(n)).
Big – O: Addition
If f(n) is O(h(n)) and g(n)
is O(h(n)), then f(n) + g(n) is O(h(n)).
Big – O
The function ank is O(nk).
Big – O
The function nk is O(nk+j)
for any positive j.
Standard Complexities
Execution times on a computer executing 1
million ops/sec (1 sec = 106 µsec)
Class
Big – O
n=10
O(1)
1 µsec
O(lg n)
3 µsec
O(n)
10 µsec
No name
O(n lg n)
33 µsec
Quadratic
O(n2)
10 µsec
Cubic
O(n3)
1 msec
Exponential
O(2n)
10 msec
Constant
Logarithmic
Linear
n=103
n=105
Determining Complexity

How can we determine the complexity of a
particular algorithm?
int sum(int* arr, int size)
{
int sum = 0;
for (int i = 0; i < size; i++)
sum += arr[i];
return sum;
}
int sum(int* arr, int size)
{
int sum = 0;
for (int i = 0; i < size; i++)
sum += arr[i];
return sum;
}
Related documents