Big O notation notes Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

what is the purpose of Big O notation ?

A

to evaluate the complexity of an algorithim

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is complexity ?

A

complexity = Time ( no of operations)
space( how much memoery an algorithim needs )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is
O(1)
O(n)
O(n^2)

A

O(1) - will always take the same amount of memory

O(n) - grows at the same rate as number of elements t

O(n^2) - time take inceases at a polynomical rate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is
O(2^n)
O(n!)
O(logn)

A

O(2^n) - time doubles with each data item

O(n!) time grows expontially

O(logn) time grows slowly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

state the complexity of
O(1)
O(n)
O(n^2)
O(2^n)
O(n!)
O(logn)

A

O(1) -constant complxity
O(n)- linear complexity
O(n^2)]- quadratic complexity
O(2^n)- exponential complexity
O(n!)-factorial complexity
O(logn)- logarithimic complexity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what are the complexities of all the search algorithms ?
best and avg(worst)?

A

Best: Avg:
inear search -o(1) o(n)
binary search-o(1) o(logn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are the complexities for all the sort algorithms ?
best and avg(worst)

A

Best: avg:

bubble sort -o(n) o(n^2)
insertion -o(n) o(n^2)
merge sort -o(nlogn) o(nlogn)
quick sort -o(nlogn) o(nlogn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly