Big O Notation Flashcards

1
Q

Define Big O Notation

A

Metric used to measure how efficient an algorithm is. How an algorithm scales with input

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

Expected Case

A

Usually the runtime that occurs on a daily basis

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

Worst Case

A

The unlucky case, usually runs the worst or is least performant

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

Best Case

A

The lucky case, usually runs the fastest

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

Dropping non dominant term

A

Getting rid of all terms smaller than the largest big O value. Constants can also be dropped

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

Space complexity

A

Big O can also be used to describe space complexity. This is usually to describe how much space is needed for a data structure IN the algorithm.

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

What is the big O of two for loops that aren’t nested and iterate through the same array length n?

A

2n, but you can drop the terms. This would run in linear time or O(n)

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

What is the big O of two for loops that are nested and iterate through the same array length n?

A

Since for each value of the first loop has to wait for a whole iteration of the second, the loop would run in O(n^2)

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