Graphs-and-Tree
Question 1 |
Which of the following is/are correct about the graph?
For each pair of vertices u and v, there is a directed path from u to v. | |
The graph does not have a strongly connected component. | |
The graph does not have a topological order. | |
A depth-first traversal staring at vertex S classifies three directed edges as back edges. |
Option-1: FALSE: There is no path from top right corner vertex to any other vertex
Option-2: FALSE: A directed graph is called strongly connected if there is a path in each direction between each pair of vertices of the graph. As there is no path from the above vertex then this statement is wrong.
Option-3: TRUE: This graph does have directed cycles, thus topological order can not be possible for according to topological definition.

Question 2 |
Let G = (V,E) be a directed, weighted graph with weight function w:E → R. For some function f:V → R, for each edge (u,v) ∈ E, define w'(u,v) as w(u,v) + f(u) - f(v).
Which one of the options completes the following sentence so that it is TRUE?
“The shortest paths in G under w are shortest paths under w’ too, _______”.
if and only if f(u) is the distance from s to u in the graph obtained by adding a new vertex s to G and edges of zero weight from s to every vertex of G | |
if and only if ∀u ∈ V, f(u) is positive
| |
if and only if ∀u ∈ V, f(u) is negative | |
for every f: V→R |

Question 3 |
S1:The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
S2:The sequence of procedure returns corresponds to a postorder traversal of the activation tree.
Which one of the following options is correct?
S1is false and S2is false
| |
S1is true and S2is true | |
S1is true and S2is false | |
S1is false and S2is true |
The given statements are true, they are well known facts.
- The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
- The sequence of returns corresponds to a postorder traversal of the activation tree.
Question 4 |
Breadth first search; acyclic | |
Topological sort; acyclic | |
Breadth first search; cyclic | |
Topological sort; cyclic |
Question 5 |
(C) and (E) are incorrect | |
(B) and (C) are incorrect | |
(B) and (E) are incorrect | |
(A) and (D) are incorrect
|
→ An even cycle graph is always 2-colourable while an odd cycle graph is 3-colourable.
→ A cycle of odd length has chromatic number 3. The chromatic number of any graph must be at least as big as the chromatic number of any of its sub-graphs, so a graph containing an odd cycle can’t be bipartite.
→ Let G be a 2-colorable graph, which means we can color every vertex either red or blue, and no edge will have both endpoints colored the same color. Let A denote the subset of vertices colored red, and let B denote the subset of vertices colored blue. Since all vertices of A are red, there are no edges within A, and similarly for B. This implies that every edge has one endpoint in A and the other in B, which means G is bipartite.
→ Statement E is false because If a graph G has O(√|V|) edges, then we can color G with O(√|V|) colors.
Question 6 |
23 | |
99 | |
4 | |
7 |
j = i +1
(or)
j = 3i
Second option will help us reach from 1 to 100 rapidly. The trick to solve this question is to think in the reverse way. Instead of finding a path from 1 to 100, try to find a path from 100 to 1.
So, the edge sequence with minimum number of edges is
1 → 3 → 9 → 10 → 11 → 33 → 99 → 100
which consists of 7 edges.
Question 7 |
A tree is a graph | |
A graph is a tree | |
Tree can have a cycle | |
Tree is a DAG |
