1: Algorithms & Graph Theory Flashcards

1
Q

Bubble Sort Algorithm (1:2, 3)

A
  1. Start at the beginning of the working list and move from left to right, comparing adjacent items
    a) If they are in order, leave them
    b) If they aren’t in order, swap them
  2. When you get to the end of the working list, the last item will be in its final position. Remove this item from the working list
  3. If you have made some swaps in the last pass, repeat steps 1 & 2
  4. When a pass is completed without any swaps, the list is in order
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Quick Sort Algorithm (6)

A
  1. Choose item at the midpoint of the list to be the first pivot
  2. Write down all the items that are less than the pivot, keeping their order in a sub-list
  3. Write down the pivot
  4. Write down the remaining items in a sub-list
  5. Repeat steps 1 to 4 for each sub-list
  6. When all the items have been chosen as pivots, stop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

First-Fit Algorithm (2)

A
  1. Take the items in the given order

2. Pack each item in the first available bin that can take it, starting from bin 1 each time

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

First-Fit Algorithm +/- (2)

A

+ Quick and easy to implement

- Not likely to lead to a good solution

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

First-Fit Decreasing Algorithm (2)

A
  1. Sort the items into descending order

2. Apply the first-fit algorithm on the reordered list

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

First-Fit Decreasing Algorithm +/- (3)

A

+ Usually get a fairly good solution
+ Quick and easy to implement
- May not get an optimal solution

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

Full-Bin Method (2)

A
  1. Use inspection to find combinations of items that will fill a bin and pack these items first
  2. Pack any remaining items using the first-fit algorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Full-Bin Method +/- (2)

A

+ Usually get a good solution

- Difficult to do, especially when the numbers are plentiful and awkward

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

Vertex / Node

A

Point on a graph

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

Edge / Arc

A

Line segment joining two vertices

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

Weight

A

Number associated with an edge

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

Weighted Graph / Network

A

Graph with weighted edges

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

Vertex Set

A

List of vertices

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

Edge Set

A

List of edges

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

Subgraph

A

Part of an original graph, all of whose vertices and edges belong to the original graph

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

Degree / Valency / Order

A

Number of edges incident to a vertex

17
Q

Even / Odd Degree

A

Even / odd number of edges incident to a vertex

18
Q

Walk

A

Route through a graph along the edges from one vertex to the next

19
Q

Path

A

Walk in which no vertex is visited more than once

20
Q

Trail

A

Walk in which no edge is visited more than once

21
Q

Cycle

A

Walk in which the end vertex is the same as the start vertex and no other vertex is visited more than once

22
Q

Hamiltonian Cycle

A

Cycle that includes every vertex

23
Q

Connected Vertices

A

Two vertices are connected if there is a path between them

24
Q

Connected Graph

A

A graph is connected if all of its vertices are connected

25
Q

Loop

A

Edge that starts and finishes at the same vertex

26
Q

Simple Graph

A

Graph in which there are no loops and there is, at most, one edge joining any pair of vertices

27
Q

Directed Edge

A

An edge with a direction associated with it

28
Q

Digraph

A

Graph with directed edges (a.k.a., directed graph)

29
Q

Euler’s Handshaking Lemma (2)

A
  • In any undirected graph, the sum of the degrees of the vertices = 2 x the number of edges
  • Thus, in any undirected graph, there is an even number of odd vertices
30
Q

Tree

A

Connected graph with no cycles

31
Q

Spanning Tree

A

Subgraph, which contains all the vertices of the original graph and is a tree

32
Q

Complete Graph

A

Graph in which every vertex is joined, by a single edge, to every other vertex (notation: K_n where n is number of vertices)

33
Q

Isomorphic Graphs

A

Graphs which show the same information but may be drawn differently

34
Q

Planar Graph

A

Graph that can be drawn in a plane such that no two edges meet except at a vertex

35
Q

Planarity Algorithm (5, 1:4))

A
  1. Identify a Hamiltonian cycle
  2. Draw a polygon with vertices labelled to mach the ones in the Hamiltonian cycle
  3. Draw edges inside the polygon to match the edges of the original graph not already represented by the polygon
  4. Make a list of all edges inside the polygon
  5. Choose any unlabelled edge in the list and label it ‘I’. If all edges are now labelled, the graph is planar
  6. Look at any unlabelled edges that cross the edge(s) just labelled:
    - If there are none, go back to step 5
    - If any of these edges cross each other, the graph is non-planar
    - If none of these edges cross each other, give them the opposite label to the edge(s) just labelled
    - If all edges are now labelled, the graph is planar. Otherwise, go back to the start of step 6
36
Q

Algorithm

A

A finite sequence of step-by-step instructions carried out to solve a problem

37
Q

Eulerian Graph

A

Connected graph, whose vertices are all even. It contains an Eulerian cycle

38
Q

Eulerian Cycle

A

Cycle, that includes every edge exactly once

39
Q

Semi-Eulerian Graph

A

Connected graph with exactly two odd vertices. It contains a trail, that includes every edge but starts and finishes at different vertices