Chapter 38 - Graphs Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a graph?

A

» An abstract data structure which are representing a complex relationship
» A set of vertices or nodes connected by adges or arcs

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

What is traversal?

A

» It is essentially the ‘cost’ of movement around the graph

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

What are the features of an undirected graph?

A

» Consists of nodes
» All edges are bidirectional - meaning they can go any direction

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

What is an edge?

A

» Represents a path/link between 2 nodes

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

What is an arc?

A

» Another name for an edge

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

What is a vertex?

A

» Each data item within a graph

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

What is a node?

A

» Another name for a vertex

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

What is a weighted edge?

A

» Edges that have some value, attached to them
» Shows the cost of traversing

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

What are the features of a directed graph?

A

» Shows direction - can be bidirectional
» Consists of nodes

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

What are the 2 possible implementations of a graph?

A

» Adjacency matrix
» Adjacency list

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

What does each row and column represent in a adjacency matrix?

A

» A node

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

What is the order of a matrix?

A

» Row then column

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

What is an adjacency matrix?

A

» A table showing which nodes in a graph are connected and if the edges are weighted
» Elements of the matrix indicate whether pairs of vertices are adjacent or not in the graph

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

What will the adjacency matrix be in an undirect graph?

A

» Symmetric

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

How can an unweighted graph be represented in a matrix?

A

» May be represented with 1s instead of weights

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

How can a weighted graph be represented in a matrix?

A

» Instead of 1s, there can be the value of the weight

17
Q

What are the advantages of an adjacency matrix?

A

» Very convenient to work with
» Adding edges is very simple

18
Q

What are the disadvantages of an adjacency matrix?

A

» A sparse graph with not many connections will leave most of the cells empty, therefore wasting space
» Using a static 2D array for it, it is harder to add or delete nodes

19
Q

What is an adjacency list?

A

» A collection of unordered lists used to represent a finite graph
» Each list describes the set of neighbours of a vertex in a graph

20
Q

How does an adjacency list look like?

A

» A list of all the nodes are created
» Each node points to a list where all the adjacent nodes to which is directly linked

21
Q

When should an adjacency list be implemented as a dictionary?

A

» When it is weighted, with each key in the dictionary being the node and the value, the edge weight

22
Q

What are the advantages of an adjacency list?

A

» Good way of representing a sparsely connected graph
» More memory efficient

23
Q

What are the disadvantages of an adjacency list?

A

» In the adjacency list, you need to list all the nodes that the node is connected to, in order to find the other node of the edge required.
» Not time efficient

24
Q

What is the page rank algorithm?

A

» An algorithm used by Google search to rank website in their search engine results

25
Q

What are the 2 ways to traverse a graph so that every node is visited?

A

» A depth - first traversal
» A breadth - first traversal

26
Q

What is a Depth-first traversal?

A

» We go as far down one route as we can before backtracking and taking the next route
» Visit the first node atatched to starting node
» Visited all the nodes connected directly or indirectly to this first node
» Visit the second node directly atteched to the starting node

27
Q

What is the data structure used for depth-first traversal?

A

» A stack

28
Q

What are the applications for depth-first searches?

A

» Finding a path between 2 vertices
» Solving a puzzles such as navigating a maze

29
Q

Is there a unique way to visit all the nodes in a depth-first search?

A

» No as the sequence involves some choices

30
Q

What is a breadth-first search?

A

» We visit all the neighbours of a node, then all the neighbours of the first node visited, and so on before moving further away from the start node

31
Q

What is the data structure used for breadth-first searches?

A

» A queue

32
Q

What are the applications for a breadth-first search?

A

» Finding the shortest path between 2 points
» Facebook used a breadth-first search to find all the friends of a given individual

33
Q

What are some applications for graphs?

A

» Computer networks
» Roads between towns
» Web pages and links

34
Q

How does a graph differ from a linked list?

A

» Each vertex can have more than 2 edges

35
Q

What does a 1 represent in an adjacency matrix?

A

» Represents an edge between 2 vertices

36
Q

What is abstraction?

A

» Using only the necessary detail and discarding unecessary detail

37
Q

In an undirected graph, what are the edges?

A

» Bidirectional