3500: Ch 3 Graphs

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is a bipartite graph?

A graph where the node set V can be partitioned into sets X and Y in such a way that every edge has one end in X and the other end in Y.

Can a simple path in a graph contain the same vertex twice.?

False. A simple path must contain distinct vertices.

True/False. A path in an undirected graph is a sequence of nodes v1,...,vk such that each consecutive pair (vi, vi+1) may or may not be joined by an edge

False. All consecutive pairs MUST be joined by an edge.

True/False. An undirected graph is connected if for every pair of vertices u & v, there may or may not be a path from u to v

False. It is only connected if there IS a path.

Does DFS use a queue?

False. It uses a stack

True/False. In an adjacency matrix we can check in O(n) time if a particular edge (u, v) is present in the graph.

False. O(1)

True/False. Let T be a depth-first search tree, let x and y be nodes in T, and let (x, y) be an edge of G that is not an edge of T. Then one of x or y may or may not be an ancestor of the other.

False. One of x or y must be an ancestor of the other. For a given recursive call DFS(u), all nodes that are marked "Explored" between the invocation and end of this recursive call are descendants of u in T.

What is the definition of a strongly connected directed graph?

For every two nodes u and v, there is a path from u to v and from v to u.

Let T be a breadth-first search tree, let x and y be nodes in T belonging to layers Li and Lj respectively, and let (x, y) be an edge of G. Is it possible for i and j to differ by more than 1?

No.

Can a DAG contain a cycle?

No. A directed acyclic graph cannot contain cycles.

Does computing a topological ordering take O(n^2)?

No. An efficient algorithm can do it in O(m+n) time

If a graph G is bipartite, can it contain an odd cycle?

No. Ex: A triangle is not bipartite since we can color one node red, another one blue, and then we can't do anything with the third node.

Is the distance between some pair of nodes u and v calculated as the average number of edges in a u-v path?

No. It is the MINIMUM number of edges (shortest path)

The adjacency list representation takes up how much space?

O(m+n)

What is the worst case run time for BFS and DFS?

The basic graph search algorithms have O(|V| + |E|)

True/False. A cycle in a graph is a path from v1, ..., vk such that the first k-1 vertices are distinct and v1 = vk

True

True/False: For each j ≥ 1, layer Lj produced by BFS consists of all nodes at distance exactly j from s. There is a path from s-->t if and only if t appears in some layer.

True

Does BFS use a queue?

True.

For a directed graph G, a topological ordering of G is an ordering of its nodes as v1, v2, . . . , vn so that for every edge (vi, vj), we have i < j.

True. All edges point "forward" in the ordering.

True/False. For any two nodes s and t in a graph, their connected components are either identical or disjoint.

True. Consider any two nodes s and t in a graph with the property that there is a path between s and t. For any node v in the component of s, the node v must also be reachable from t by a path: we can just walk from t to s, and then on from s to v. The same reasoning works with the roles of s and t reversed, and so a node is in the component of one if and only if it is in the component of the other.

True/False. The adjacency matrix takes up Θ(n^2) space

True. It uses a n x n matrix

True/False. In an adjacency list, checking if a particular edge (u,v) is in a graph takes O(degree of v) time.

True. We must iterate over v's list of neighbors to check if u is there

Does BFS compute the shortest path to a node starting from the starting node?

Yes

Does every n-node tree have n-1 edges?

Yes

If G is a DAG, does G have a topological ordering?

Yes

Is an undirected graph a tree if it is connected and does not contain a cycle?

Yes

Let G be a connected graph, and let L1, L2, . . . be the layers produced by BFS starting at node s. If there is no edge of G joining two nodes of the same layer, is the graph bipartite?

Yes

Let G be an undirected graph on n nodes. If G does not contain a cycle and has n-1 edges, can we conclude it is connected?

Yes

If G has a topological ordering, is G a DAG?

Yes, it must be a DAG. A topological ordering on tasks provides an order in which they can be safely performed; when we come to the task vj, all the tasks that are required to precede it have already been done, therefore there cannot be cycles.

Let G be an undirected graph on n nodes. If G is connected & does not contain a cycle, can we conclude it has n-1 edges?

Yes.

In every DAG G, must there exist a node v with no incoming edges?

Yes. There must be at least one node v with no incoming edges.

If u and v are mutually reachable, and v and w are mutually reachable, then should u and w be mutually reachable?

Yes. To construct a path from u to w, we first go from u to v (along the path guaranteed by the mutual reachability of u and v), and then on from v to w (along the path guaranteed by the mutual reachability of v and w).


Kaugnay na mga set ng pag-aaral

Anatomy and Physiology chapter 1

View Set

Lab Exercise 44: Embryonic Development

View Set

Stress Management Chapter 2 (always can take quiz again)

View Set

Finance 450 Final (Ch. 12, 13, 14)

View Set

Chapter 1 Fundamentals CoursePoint

View Set