u5 Flashcards

1
Q

optimisation problem

A

one in which the task is to find the best possible solution

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

priority queue

A

each item has a priority and items are kept sorted with the highest priority item at the front.
•When a new item is added it is inserted at its correct position in the priority order.
•The priority of an item in the queue maybe changed, whereupon the queue will be reordered

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

Graphs

A

A graph is a set of verticesor nodes, together with a set of edgesor arcs, each connecting one vertex to another. Edges may have weights.
•If V is the set of vertices in a graph, then |V| is the number of vertices.
•If E is the set of edges, then |E| is the number of edges.

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

digraph or directed graph

A

a graph in which each edge has a direction

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

complete graph

A

has an edge between every pair of vertices

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

sparse graph

A

few edges(vertices have few neighbours)

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

dense graph

A

has many edges (vertices have many neighbours).

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

general tree

A

an empty tree or a root with 0 or more subtrees

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

Depth-first search

A

starts at a specified vertex and explores as far as possible along each branch before backtracking.
•Depth-first search is what happens automatically by recursively iterating over neighbours.
•Vertices are marked to avoid visiting them more than once.

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

Breadth-first search

A

starts at a specified vertex and explores the neighbour nodes first, before moving to the next level of neighbours.
•BFS can be implemented by keeping a “to do” list of vertices as a queue.

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

The minimum distance problem/shortest path

A

Find the shortest distance from a specified source vertex v to each of the other vertices.

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

Dijkstra’s algorithm

A

Solution to the shortest path
create a priority queue(with priority higher for smaller values)
set distance(v)to 0
set distance(w)to infinity for all other vertices w
add all vertices to the priority queuewith priority equal to their distance
ITERATEwhile the priority queueis not empty
remove u from the front of the queue
ITERATE over vertices wthat are neighbours of u
set new-distanceto distance(u)+ length of edge uw
IF new-distanceis less than distance(w)
set distance(w)to new-distance
change the priority of w in the priority queue to new-distance

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

Spanning trees

A

a subset of the graph’s edges that connect all the vertices, without including any closed circuits.
•It contains a minimal set of edges that connect up all the nodes.The number of edges in a spanning tree is |V| –1.

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

minimum spanning tree

A

a weighted graph is a spanning tree that minimises the sum of the weights along its edges.

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

Prim’s algorithm

A

a greedy solution to the problem of finding a MST
•Start from an arbitrary vertex.
•Keep vertices not already in the current tree in a priority queue.
•Keeptrack of the shortest edge that could connect a vertex to the current tree.
•Use the length of these edges to order the priority queue.
•At each step, add the vertex closest to the current tree to the tree

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

directed acyclic graph

A

a directed graph with no directed cycles.

•DAGs are useful for representing dependencies.

17
Q

Topological sort

A

orders the vertices of a DAG so that, for every directed edge uv, ucomes before vin the ordering.
•Identify a vertex with no incoming edges and add it to the topological sort.
•Remove that vertex and all its outgoing edges from the graph.
•Repeat until all the vertices have been removed.
Rather than literally removing vertices and edges, a dictionary records how many edges come into each vertex.