ch 9 graph algorithms Flashcards

1
Q

directed

A

if pair of vertices is ordered, edge has a direction

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

DAG

A

directed acyclic graph, no cycles

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

connected

A

every vertice is directly connected to each other

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

strongly connected

A

directed graph with every vertice connected to each other

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

weakly connected

A

no direction

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

complete graph

A

edge between every vertice

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

adjacency matrix vs adjacency graph

A
adjacency matrix when graph is dense
each edge (u,v) set A[u] [v] to true 

sparse: adjacency list
for each vertex, keep a list of adjacent vertices
memory requirement is larger

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

topological sort

A

ordering of vertices in a directed acyclic graph, such that if there is a path from vi to vj, then vj appears after vi in the ordering
not possible if there is a cycle

decrease indegree every time you traverse the vertex within a vertex’s adjacency list

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

negative cost cycle

A

cannot be found when present

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

running time of unweighted shortest path problem

A

O(E +V)

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

running time of weighted shortest path problem

A

O(E log v)

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

breadth first search

A

processing vertices in layers

vertices closest to the start are evaluated first , most distant vertices are calculated last

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

minimum spanning tree

A

tree because a cyclic

spanning because it covers every vertex

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

prims algorithm

A
essentially dijkstras
start with a node
see which adjacent node has the shortest path
mark that as known
now see which has the shortest path
mark them as known
etc
good example in the book
runs on undirected graphs 
runtime V^2 without heaps, or ElogV with heaps
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

kruskals

A

selected edges in order of the smallest weight and accept an edge if it does not cause a cycle
if u and v are in the same set, they are rejected
for example, you have u v w in a triangle
join u and v, they are in a set
join v and w they are in a set
when you see w and v, they are both already in the same set

on paper
see which weights are the smallest
create an edge between them if it doesnt create a cycle
good example on page 398

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

undecidable problems

A

impossible problems

17
Q

halting problem

A

having compiler check for infinite loops

18
Q

NP

A

nonterministic polynomial time