Problem Set-4 Help Center

Learn more

Warning: You have already made the maximum number of submissions. Additional submissions will not count for credit. You are welcome to try it as a learning exercise.

Question 1

Given an adjacency-list representation of a directed graph, where each vertex maintains an array of its outgoing edges (but *not* its incoming edges), how long does it take, in the worst case, to compute the in-degree of a given vertex? As usual, we use nn and mm to denote the number of vertices and edges, respectively, of the given graph. Also, let kk denote the maximum in-degree of a vertex. (Recall that the in-degree of a vertex is the number of edges that enter it.)

Question 2

Consider the following problem: given an undirected graph GG with nn vertices and mm edges, and two vertices ss and tt, does there exist at least one ss-tt path?
If GG is given in its adjacency list representation, then the above problem can be solved in O(m+n)O(m+n) time, using BFS or DFS. (Make sure you see why this is true.)
Suppose instead that GG is given in its adjacency *matrix* representation. What running time is required, in the worst case, to solve the computational problem stated above? (Assume that GG has no parallel edges.)

Question 3

This problem explores the relationship between two definitions about graph distances. In this problem, we consider only graphs that are undirected and connected. The diameter of a graph is the maximum, over all choices of vertices ss and tt, of the shortest-path distance between ss and tt. (Recall the shortest-path distance between ss and tt is the fewest number of edges in an ss-tt path.)
Next, for a vertex ss, let l(s)l(s) denote the maximum, over all vertices tt, of the shortest-path distance between ss and tt. The radius of a graph is the minimum of l(s)l(s) over all choices of the vertex ss.
Which of the following inequalities always hold (i.e., in every undirected connected graph) for the radius rr and the diameter dd? [Select all that apply.]

Question 4

Consider our algorithm for computing a topological ordering that is based on depth-first search (i.e., NOT the "straightforward solution"). Suppose we run this algorithm on a graph GG that is NOT directed acyclic. Obviously it won't compute a topological order (since none exist). Does it compute an ordering that minimizes the number of edges that go backward? For example, consider the four-node graph with the six directed edges (s,v),(s,w),(v,w),(v,t),(w,t),(t,s)(s,v),(s,w),(v,w),(v,t),(w,t),(t,s). Suppose the vertices are ordered s,v,w,ts,v,w,t. Then there is one backwards arc, the (t,s)(t,s) arc. No ordering of the vertices has zero backwards arcs, and some have more than one.

Question 5

On adding one extra edge to a directed graph GG, the number of strongly connected components...?
    
You cannot submit your work until you agree to the Honor Code. Thanks!