comp 2 num 2 Flashcards

1
Q

What is an algorithm?

A

Step by step instructions to solve a problem.

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

What is O(1)?

A

constant time complexity, Time requirements do not change as the size of the input increases.

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

What is O(n)?

A

linear time complexity, Time requirements increase in direct proportion to the size of the input.

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

What is O(n^2)?

A

quadratic time complexity, Time requirements increase in proportion to the size of the input squared.

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

What is O(n^k)?

A

polynomial time complexity

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

What is O(k^n)?

A

exponential time complexity, A small increase in the size of the input results in a disproportionate exponentially large increase in the time requirements.

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

What is O(logn)?

A

logarithmic time complexity, As the size of the input increases, the time requirements increase at a decreasing rate.

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

What is the best to worst order for these?

A

1
logn
n
nlogn
n^2
n^k
k^n

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

What is always the best case time for a search algorithm?

A

o(1)

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

What is the worst case time complexity for each search/sort alg?

A

linear search n
binary search logn
bubble sort n^2
insertion sort n^2
merge sort nlogn
quick sort nlogn

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

Why is a merge sort nlogn?

A

Splitting array recursively until all arrays are of length 1 is logn.
Combining these n number of sublists results in multiplying by n to result in nlogn.

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

What is the purpose of big o?

A

Evaluating the complexity of an algorithm in relation to space and time requirements and how they scale as the input size increases.

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