Test 2 Flashcards

1
Q

For some problems, a top-down divide-and conquer decomposition results in smaller instances which are related , resulting in : .

Example : Fib Algorithm 1.6

A

Very inefficient solutions

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

In _____________, smaller instances solved first, the results are stored, and reused later if needed.

A

Dynamic Programming

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

Dynamic programming is a __________ approach that stores partial solutions , typically in an array .

A

“bottom-up”

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

Using the dynamic programming method:

A
  1. Establish a recursive property that gives the solution to an instance of the problem .
  2. Solve an instance of the problem in a bottom-up fashion by solving smaller instances first . In the process , store partial solutions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

To solve an optimization problem using dynamic programming, the principle of optimality must apply:

A

an optimal solution to an instance of a problem always contains optimal solutions to all subinstances.

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

When the principle of optimality applies , we can

A
  1. Establish a recursive property that gives the optimal solution to an instance of the problem ,
  2. Compute the value of an optimal solution in a bottom-up fashion ,
  3. Construct the optimal solution in a bottom-up fashion
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The goal is to maximize the value that can hold at most a total weight W of goods from a set of items

A

Knapsack

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

To save a record of a knapsack problem you must:

A

To compute the actual subset, we add an auxiliary boolean array keep[i, w] which is true if the i ^ (th) item is kept in P[i, w] , false otherwise.

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

A greedy algorithm works in phases. At each phase :

A

You take the best you can get right now , without regard for future consequences (or past events )

You hope that by making a locally optimal choice at each step, you will end up with a globally optimal solution

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

algorithm starts with an empty “chosen” set and adds items to the set until a solution is obtained

A

greedy

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

Each iteration for greedy requires :

A

selection procedure: pick the next item that appears to be the “best “ according to a “ local “ criterion

feasibility check: determine if it is feasible to add the chosen item to the set within problem constraints

A solution check: do we have a solution to the problem ?

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

For optimization problems , greedy algorithms are often simpler and more efficient, but:

A

do not always produce optimal results

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

___________ programming produces optimal results provided that the principle of optimality applies.

A

Dynamic

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

Any problem that can be solved by a _______ algorithm can be solved by ________ programming , but not the other way around.

A

greedy

dynamic

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

If fractions of items are allowed , a greedy approach:

A

yields an optimal solution

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

If no fractions allowed , greedy approaches are ______________ to yield optimal solutions

A

not guaranteed

17
Q

We can place objects or fractions of objects in the knapsack, as long as W:

A

is not exceeded

18
Q

A minimum spanning tree is a spanning tree with _______ overall weight .

A

lowest

19
Q

Numerous applications of this apllication: road construction, network cabling , etc.

A

Minimum spanning tree

20
Q

Start by picking any vertex and adding it to the tree

Repeatedly: Pick any least- cost edge from a vertex in the tree to a vertex not in the tree, and add the edge and new vertex to the tree

Stop when all vertices have been added to the tree

A

Prim’s algorithm

21
Q

uses the greedy approach to find the shortest paths from a given source to all other vertices in a graph.

A

Dijkstra’s algorithm

22
Q

Dijkstra’s algorithm complexity is:

A

O(n ^ 2) complexity