Week 8 - Greedy Algorithms Flashcards

1
Q

What is a greedy algorithm?

A

A greedy algorithm is an approach that makes the locally optimal choice at each step with the hope of finding the global optimum. It solves problems by choosing the best option available at the moment, without considering the broader context.

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

What is the knapsack problem?

A

The knapsack problem involves selecting a combination of items with given weights and values to maximize the total value without exceeding a weight limit, such as a knapsack’s capacity of 35 kg.

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

What is the downside of greedy algorithms?

A

The downside of greedy algorithms is that they may not always produce the optimal solution for all problems, as they only consider local optimal choices and can miss the globally optimal solution.

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

What is a set covering problem?

A

The set covering problem involves finding the smallest subset of sets that covers all elements in a universal set, minimizing the total number of sets used.

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

What is an example of a set covering problem?

A

An example of a set covering problem is selecting a subset of radio stations to play on in order to cover all cities across Australia while minimizing costs, given that each station covers different cities with some overlaps.

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

What is a powerset?

A

The powerset of a set is the set of all possible subsets, including the empty set and the set itself. This is 2^n possible subsets.

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

What is the naive “brute force” for a set covering problem?

A

The naive “brute force” approach for a set covering problem involves two steps:

  1. List all possible subsets: Generate every possible subset of sets, which amounts to (2^n) subsets, where (n) is the total number of sets.
  2. Select the optimal subset: Identify the smallest subset from these that covers all elements in the universal set.

The time complexity is O(2^n) which is impractical for large values of n.

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

What algorithm can be used to solve a set covering problem in a reasonable time?

A

An approximation algorithm for the set covering problem is the Greedy Approximation Algorithm. It involves:

  1. Selecting the Set: Pick the station (or set) that covers the most cities, even if it overlaps with some cities already covered.
  2. Repeating: Continue selecting sets until all cities are covered.

This approach provides a “good enough” solution efficiently.

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

List some of the operators for sets.

A

Some common operators for sets include:

  • Union (|): Combines all unique elements from both sets.
  • Intersection (&): Finds common elements present in both sets.
  • Difference (-): Identifies elements in one set that are not in the other.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the two key factors on which approximation algorithms are evaluated?

A

The two key factors on which approximation algorithms are evaluated are:

  1. Speed: How quickly the algorithm can compute a solution.
  2. Quality: How close the computed solution is to the optimal solution.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are NP-complete problems?

A

NP-complete problems are a class of problems for which finding an exact solution requires examining all possible solutions (brute force), leading to exponential time complexities, such as (O(2^n)) for the Set-Covering Problem and (O(n!)) for the Traveling Salesman Problem (TSP). These problems are both difficult to solve and to verify efficiently.

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

How can you recognise an NP-complete problem?

A

To recognize an NP-complete problem, look for characteristics such as the need to examine all combinations or possible solutions, difficulty in breaking the problem into smaller sub-problems, and challenges with sequences or sets. If the problem can be reduced to or restated as a known NP-complete problem like the set-covering problem or the traveling-salesperson problem, it is likely NP-complete.

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