Complexity Flashcards

1
Q

Time complexity

A

Is a measure of the amount of time it takes for an algorithm to run as function of the input size. It provides an estimate of how the algorithms runtime grows as the input size increases. It usually expresses by big O notation.

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

O(1)

A

Constant time. The algorithms runtime remains content regardless of the input size.
Example:
Accessing a specific index within an array: arr[0]

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

O(log n)

A

Logarithmic time. The algorithms runtime grows logarithmically with the input size.
Example: binary search tree

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

O(n)

A

Linear time. The algorithms runtime grows in direct proportion to the size of the input data.
Example: for loop

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

O(n log n)

A

Linearithmitic time. The algorithms runtime grows in proportion to the product of the input size and its logarithm.
Example: merge sort

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

O(n^2)

A

Quadratic time. The algorithms runtime grows quadratically with the input size.
Example: nested for loops

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

O(2^n)

A

Exponential time. The algorithms runtime grows exponentially with the input size.
Example: double recursive method

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