Greedy algorithms Flashcards

1
Q

What is Greedy?

A

Make a local optimal choice in hope that it will ultimately lead to global optimal solution.

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

Greedy specifics

A
  1. Control-function
  2. Selection-function
  3. Feasibility function
  4. Objective function
  5. Solution function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Greedy requirements!!!

A
  1. Feasible
  2. local optimal
  3. irrevocable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Dijkstra’s algorithm

A

Choose starting node. Continue to keep track of final score and last visited node. Begin by looking at all edges from starting node and value which one is the best etc. Proceed to the nodes that are directly connected to the starting node and repeat process. Remember not to compare against the node that you came from, however compare against nodes that you have visited before but from a different position. If new path has smaller value then replace it.

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

Minimum spanning tree

A

a way to connect all nodes with smallest final weight (value).

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

Prim’s algorithm

A

Begin with selecting any vertex. Look at all the edges that the vertex has and choose the one with smallest weight (value). Now you have 2 vertices in your solution. Look at all the edges available from those vertices and choose the one with smallest value. Repeat until all vertices are in solution.

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

Kruskal’s algorithm

A

Find and start with edge with smallest weight. Find the second smallest edge that doesn’t create a cycle with previously selected edges. Repeat until all vertices are in solution.

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

Difference between Prim and Kruskal?

A

Prim: vertex approach
Kruskal: smallest weight edge approach

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