7 - Algorithms Flashcards

1
Q

What is a “Eulerian circuit”?

A

A circuit which includes EVERY edge of the graph exactly ONCE

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

What is a “Eulerian graph”?

A

A graph which has a Eulerian circuit

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

What is a “Eulerian trail”?

A

A walk with uses each edge exactly once (also called a Semi-Eulerian)

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

What is important to remember about Eulerian trails?

A

Starts at one of the odd vertices and ends at the other

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

What is a “Hamiltonian cycle”?

A

Visits each vertex exactly once and returns to the starting vertex

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

What is a “Hamiltonian graph”?

A

When a graph has a Hamiltonian cycle

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

What is a “Hamiltonian path”?

A

A path where each vertex is visited exactly once

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

What is Kruskal’s algorithm?

A

Kruskal’s Algorithm builds a minimum spanning tree by adding edges at a time

  1. Sort all edges from low weight to high
  2. Take the edge with the lowest weight and add it to the spanning tree.
    –> If the edge created a cycle, then reject this edge
  3. Keep adding edges until we reach all vertices
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Prim’s algorithm?

A

Kruskal’s algorithm may be difficult to implement on large graphs (tough to check for cycles), therefore we use Prim’s algorithm!
Prim’s algorithm builds up the tree by adding vertices one at a time

  1. Specify a starting vertex
  2. At each stage find the vertex (which has not yet been added) that has the shortest possible distance to any of the vertices that have already been added.
  3. Stop when all vertices have been connected
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the Chinese postman problem?

A

The Chinese postman problem is to find the shortest path around the graph which uses each edge at least once and returns to the starting point.
–> IF the graph is Eulerian, the Eulerian cycle is a solution to the problem

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

How is the Chinese postman problem carried out if there are 2 odd vertices?

A
  1. Identify the two vertices of odd degree
  2. Find the shortest path between those two vertices
  3. The edges in this shortest path need to be used twice, all other edges only once
  4. The length of the route is the total weight of all the edges plus the length of the edges that are used twice (the shortest path from the previous step)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How is the Chinese postman problem carried out if there are 4 odd vertices?

A
  1. Write down all possible pairing between the four odd vertices (should be 3)
  2. For each pairing possibility, find the total of the shortest distances between the two vertices in a pair
  3. Select the pairing which gives the smallest total. The corresponding edges need to be repeated.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the Traveling salesman problem?

A

The travelling salesman problem is to find the shortest route around a graph which visits each vertex at least once and returns to the starting point.
–> This is difficult to do, so you must calculate an UPPER and LOWER bound

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

How would you calculate the UPPER BOUND for the Traveling salesman problem?

A

Nearest Neighbor Algorithm:

  1. pick a starting vertex
  2. go to the closest vertex not yet visited
  3. repeat until all vertices have been used
  4. add the final edge to return to the starting vertex
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How would you calculate the LOWER BOUND for the Traveling salesman problem?

A

Deleted Vertex Algorithm:

  1. remove one vertex and all associated edges
  2. find the length of the minimum spanning tree for the remaining graph
  3. add the two shortest edges that were originally connected to the removed vertex
How well did you know this?
1
Not at all
2
3
4
5
Perfectly