Data Structures & Algorithms Flashcards

1
Q

What is Big O Notation?

A

A numeric representation of the efficiency of code

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

Big O Notation is a ____ way of talking about how efficient an algorithm is.

A

Generalized.

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

0(n)

A

Linear time complexity. The algorithm’s runtime increases linearly with the input size.

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

0(1)

A

Constant time complexity. The algorithm’s runtime is constant regardless of the input size.

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

0(n^2)

A

Quadratic time complexity. The algorithm’s runtime increases quadratically with the input size.

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

Time complexity describes…

A

how an algorithm’s performance scales as the size of the input increases.

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

Auxiliary space complexity…

A

refers to the amount of additional memory space required by an algorithm beyond the input size to solve a problem.

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

Rules of Thumb for space complexity:
1) Most primitives (booleans, numbers, undefined, null)….
2) Strings require ____ space …
3) Reference types are generally ____ space…

A

1) Take up constant space.
2) O(n) space … where n is the string length.
3) O(n) space … where n is the length (for array’s) or the number of keys (objects).

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

O(logN)

A

O(logN) time complexity, refers to a situation where the number of steps necessary to complete a task increases in proportion to the logarithm of the input size.

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

O(NLogN)

A

time complexity represents a scenario where the time an algorithm takes grows in proportion to N (the size of the input) multiplied by logN (the logarithm of N).
This complexity is seen in algorithms that perform a logarithmic operation multiple times, once for each element in the input.

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

O(2^N)

A

Represents exponential time complexity. Signifies that the execution time of an algorithm grows exponentially with the size of the input. For each additional element in the input, the execution time of the algorithm doubles.

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

What is a good example of an algorithm with exponential time complexity?

A

A common example of an algorithm with exponential time complexity is non-memoized recursion. In such cases, the algorithm often recalculates the same subproblems multiple times, leading to a dramatic increase in the number of operations.

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