Algorithms Flashcards

(13 cards)

1
Q

What is the purpose of algorithm analysis?

A

To evaluate the time and space an algorithm uses so we can compare efficiency.

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

What is Big O notation?

A

A mathematical way to describe the upper bound of an algorithm’s time or space complexity.

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

What is O(1) time complexity?

A

Constant time – the algorithm takes the same time regardless of input size.

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

What is O(n) time complexity?

A

Linear time – time grows directly in proportion to input size.

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

What is O(n²) time complexity?

A

Polynomial time – time grows proportionally to the square of the input size.

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

What is O(log n) time complexity?

A

Logarithmic time – time increases slowly as input size grows.

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

What is O(2ⁿ) time complexity?

A

Exponential time – time doubles with each additional input element, very inefficient.

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

What is Dijkstra’s algorithm used for?

A

To find the shortest path between two nodes in a weighted graph.

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

How does Dijkstra’s algorithm work?

A

It uses a priority queue to repeatedly visit the nearest unvisited node and update shortest path estimates.

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

What is A* (A-star) algorithm used for?

A

To find the shortest path efficiently using a heuristic to guide the search.

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

How does A* differ from Dijkstra’s?

A

A* adds a heuristic estimate to the total cost, making it faster in many cases.

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

When is an algorithm suitable for a problem?

A

When it solves the problem correctly and efficiently for the size and type of data involved.

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

What factors affect an algorithm’s suitability?

A

Input size, time complexity, memory usage, and structure of data.

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