Graph/Tree Flashcards

1
Q

What are two sets that determine a graph?

A

G(V, E). A set of vertices | V | and set of edges | E |.

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

What are graph properties?

A
  1. Weight (weighted/unweighted)
  2. Directionality (directed/undirected)
  3. Path
  4. Cycle
  5. Connectivity
  6. Vertex Degree
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a weighted graph vs an un-weighted graph?

A

A graph that has numerical weights associated with every edge, while there are no weights in an un-weighted graph.

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

What is a directed graph vs un-directed graph?

A

In a directed graph, there are certain ways that could be travelled between nodes (like a one-way street) while in an undirected graph, either way can be travelled through edges (bidirectional).

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

What is a path?

A

A path is a sequence of vertices that are connected to edges.
ex. A->B->C->B->C

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

What is a simple path?

A

A simple path is a path with no vertices repeated.

ex. A->B->C

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

What is a cycle?

A

A cycle is a simple path that start and end at the same node.

ex. A->B->C->A

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

What is a connected graph?

A

A graph where there exists a path between every 2 vertices (otherwise disconnected).

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

What is a bipartite graph?

A

A graph where all vertices can be divided into two sets: V1 and V2 such that

V1 ⋃ V2 = V (all vertices are used) (Union is OR)

AND

V1 ⋂ V2 = Ø (no vertices belong to both V1 and V2) (Intersection is AND)

AND
Vertexes are adjacent only between elements of V1 and V2.

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

What is a vertex degree in an UNDIRECTED graph?

A

The number of edges adjacent to the particular vertex.

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

What are vertex degrees in a DIRECTED graphs composed of?

A

Indegrees and outdegrees.

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

What is an indegree in a directed graph?

A

The number of edges that point to a vertex.

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

What is an outdegree in a directed graph?

A

The number of edges that start from a particular vertex.

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

What is a clique?

A

A strongly connected, undirected graph in which every two vertices have an edge.

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

An “n-clique” clique has n edges.

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

What is the relationship amongst number of edges in a clique and the number of vertices.

A

Arithmetic series.

|E| = (V(V-1))/2

17
Q

What are two ways graphs are represented?

A

Adjacency List / Adjacency Matrix (V x V).

18
Q

When should you use an adjacency matrix to represent a graph?

A

Use an adjacency matrix when time is critical (only O(1), compared to O(n) for list).

19
Q

When should you use an adjacency list to represent a graph?

A

Use an adjacency list when space is critical (O(E) (or O(n^2) for worst case compared to O(n^2) for matrix).

20
Q

What is a tree?

A

A tree is a graph that is connected, acyclic, and undirected.

21
Q

What is a root node in a tree?

A

The topmost node of a tree that does not have any parent node.

22
Q

What can you do if a tree does not have a specified root?

A

You can take any vertex and name it as root.

23
Q

What is a leaf node in a tree?

A

Leaf nodes are nodes which do not have any child nodes.

24
Q

What is a parent node in a tree?

A

The node which is a predecessor of a node is called the parent of that node.

25
Q

What is a child node in a tree?

A

The node which is the immediate successor of a node is called the child of that node.

26
Q
A