Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Tests  >  Test: Graph - 2 - Computer Science Engineering (CSE) MCQ

Test: Graph - 2 - Computer Science Engineering (CSE) MCQ


Test Description

20 Questions MCQ Test - Test: Graph - 2

Test: Graph - 2 for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Test: Graph - 2 questions and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus.The Test: Graph - 2 MCQs are made for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Graph - 2 below.
Solutions of Test: Graph - 2 questions in English are available as part of our course for Computer Science Engineering (CSE) & Test: Graph - 2 solutions in Hindi for Computer Science Engineering (CSE) course. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free. Attempt Test: Graph - 2 | 20 questions in 60 minutes | Mock test for Computer Science Engineering (CSE) preparation | Free important questions MCQ to study for Computer Science Engineering (CSE) Exam | Download free PDF with solutions
Test: Graph - 2 - Question 1

The Breadth First Search algorithm has been implemented using the queue data structure. One possible order of visiting the nodes of the following graph is

Detailed Solution for Test: Graph - 2 - Question 1

Option (A) is MNOPQR. It cannot be a BFS as the traversal starts with M, but O is visited before N and Q. In BFS all adjacent must be visited before adjacent of adjacent.
Option (B) is NQMPOR. It also cannot be BFS, because here, P is visited before O.
(C) and (D) match up to QMNP. We see that M was added to the queue before N and P (because M comes before NP in QMNP). Because R is M’s neighbor, it gets added to the queue before the neighbor of N and P (which is O). Thus, R is visited before O.

Test: Graph - 2 - Question 2

Let G be an undirected graph. Consider a depth-first traversal of G, and let T be the resulting depth-first search tree. Let u be a vertex in G and let v be the first new (unvisited) vertex visited after visiting u in the traversal. Which of the following statements is always true?

Detailed Solution for Test: Graph - 2 - Question 2

In DFS, if 'v' is visited
after 'u', then one of the following is true.
1) (u, v) is an edge.
     u
   /   \
  v     w
 /     / \
x     y   z

2) 'u' is a leaf node.
     w
   /   \
  x     v
 /     / \
u     y   z 
In DFS, after visiting a node, we first recur for all unvisited children. If there are no unvisited children (u is leaf), then control goes back to parent and parent then visits next unvisited children.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Graph - 2 - Question 3

Consider the following graph,

Among the following sequences:
(I) a b e g h f 
(II) a b f e h g
(III) a b f h g e 
(IV) a f g h b e  
Which are depth first traversals of the above graph?

Detailed Solution for Test: Graph - 2 - Question 3

We can check all DFSs for following properties.

In DFS, if a vertex 'v' is visited
after 'u', then one of the following is true.
1) (u, v) is an edge.
     u
   /   \
  v     w
 /     / \
x     y   z

2) 'u' is a leaf node.
     w
   /   \
  x     v
 /     / \
u     y   z
In DFS, after visiting a node, we first recur for all unvisited children. If there are no unvisited children (u is leaf), then control goes back to parent and parent then visits next unvisited children.

Test: Graph - 2 - Question 4

Consider the DAG with Consider V = {1, 2, 3, 4, 5, 6}, shown below. Which of the following is NOT a topological ordering?

Detailed Solution for Test: Graph - 2 - Question 4

In option D, 1 appears after 2 and 3 which is not possible in Topological Sorting.
In the given DAG it is directly visible that there is an outgoing edge from vertex 1 to vertex 2 and 3 hence 2 and 3 cannot come before vertex 1 so clearly option D is incorrect topological sort.
But for questions in which it is not directly visible we should know how to find topological sort of a DAG.

Test: Graph - 2 - Question 5

Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time on Depth First Search of G? Assume that the graph is represented using adjacency matrix.

Detailed Solution for Test: Graph - 2 - Question 5

Depth First Search of a graph takes O(m+n) time when the graph is represented using adjacency list.

In adjacency matrix representation, graph is represented as an “n x n” matrix. To do DFS, for every vertex, we traverse the row corresponding to that vertex to find all adjacent vertices (In adjacency list representation we traverse only the adjacent vertices of the vertex). Therefore time complexity becomes O(n2)

Test: Graph - 2 - Question 6

Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first checking that the vertex has not been visited earlier. Then the maximum possible recursion depth (including the initial call) is _________.

Detailed Solution for Test: Graph - 2 - Question 6

The following diagram shows the worst case situation where the recursion tree has maximum depth.


So the recursion depth is 19 (including the first node).

Test: Graph - 2 - Question 7

Let T be a depth first search tree in an undirected graph G. Vertices u and n are leaves of this tree T. The degrees of both u and n in G are at least 2. which one of the following statements is true?

Detailed Solution for Test: Graph - 2 - Question 7

Below example shows that A and B are FALSE:

Below example shows C is false:

Test: Graph - 2 - Question 8

In a depth-first traversal of a graph G with n vertices, k edges are marked as tree edges. The number of connected components in G is

Detailed Solution for Test: Graph - 2 - Question 8

Tree edges are the edges that are part of DFS tree.  If there are x tree edges in a tree, then  x+1 vertices in the tree.
The output of DFS is a forest if the graph is disconnected.  Let us see below simple example where graph is disconnected.


The above example matches with D option

More Examples:
1) All vertices  of Graph are connected.  k must be n-1.  We get number of connected components  = n- k =  n – (n-1) = 1
2) No vertex is connected. k must be 0.  We get number of connected components  = n- k =  n – 0 = n

Test: Graph - 2 - Question 9

Consider the following directed graph.

The number of different topological orderings of the vertices of the graph is

Detailed Solution for Test: Graph - 2 - Question 9

Following are different 6 Topological Sortings
a-b-c-d-e-f
a-d-e-b-c-f
a-b-d-c-e-f
a-d-b-c-e-f
a-b-d-e-c-f
a-d-b-e-c-f

Test: Graph - 2 - Question 10

In an adjacency list representation of an undirected simple graph G = (V, E), each edge (u, v) has two adjacency list entries: [v] in the adjacency list of u, and [u] in the adjacency list of v. These are called twins of each other. A twin pointer is a pointer from an adjacency list entry to its twin. If |E| = m and |V | = n, and the memory size is not a constraint, what is the time complexity of the most efficient algorithm to set the twin pointer in each entry in each adjacency list?

Detailed Solution for Test: Graph - 2 - Question 10

First you need to find twins of each node. You can do this using level order traversal (i.e., BFS) once. Time complexity of BFS is Θ(m +n).
And you have to use linked list for representation which is extra space (but memory size is not a constraint here).
Final, time complexity is Θ(m + n) to set twin pointer.

Test: Graph - 2 - Question 11

Let G = (V, G) be a weighted undirected graph and let T be a Minimum Spanning Tree (MST) of G maintained using adjacency lists. Suppose a new weighed edge (u, v) ∈ V×V is added to G. The worst case time complexity of determining if T is still an MST of the resultant graph is

Detailed Solution for Test: Graph - 2 - Question 11

As T is a minimum spanning tree and we need to add a new edge to existing spanning tree.
Later we need to check still T is a minimum spanning tree or not, So we need to check all vertices whether there is any cycle present after adding a new edge.
All vertices need to traverse to confirm minimum spanning tree after adding new edge then time complexity is O(V).

Test: Graph - 2 - Question 12

Consider a complete binary tree with 7 nodes. Let A denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root. Let B denote the set of first 3 elements obtained by performing Depth-First Search (DFS) starting from the root.
The value of ∣A−B∣ is _______.

Detailed Solution for Test: Graph - 2 - Question 12

In case of BFS if we draw complete binary tree then in Set A we have level1+level2.
In DFS we have level1+ level 2 + level 3.

So A-B= remaining element of level 2.

Test: Graph - 2 - Question 13

In a directed acyclic graph with a source vertex s, the quality-score of a directed path is defined to be the product of the weights of the edges on the path. Further, for a vertex v other than s, the quality-score of v is defined to be the maximum among the quality-scores of all the paths from s to v. The quality-score of s is assumed to be 1.

The sum of the quality-scores of all vertices on the graph shown above is _______ .

Detailed Solution for Test: Graph - 2 - Question 13

Let Q(V) denote the quality-score of vertex V.

Q(S) = 1 (Given)
Q(C) = 1 (S → C)
Q(F) = 1 * 9 (S  → C  → F)
Q(A) = 9 (S  → A)
Q(D) = 9*1 (S  → A  → D)
Q(G) = 9 * 1 * 9 (S  → A  → D  → G)
Q(B) = 9 * 1 (S  → A  → B)
Q(E) = 9 * 1 * 9 (S  → A  → D  → E)
Q(T) = 9*1*9*9 (S  → A  → D  → E → T) 
Sum of quality-score of all vertices,

= 1 + 1 + 9 + 9 + 9 + 81 + 9 + 81 + 729 
= 929 

Test: Graph - 2 - Question 14

Let G be the graph with 100 vertices numbered 1 to 100. Two vertices i and j are adjacent iff |i−j|=8 or |i−j|=12. The number of connected components in G is

Detailed Solution for Test: Graph - 2 - Question 14

When vertices are arranged with difference of 8 there are 8 components as shown by 8 columns in the image below:

When vertices are arranged with difference of 12 the number of components is reduced to 4 as first column will be connected with fifth column, second column will be connected with sixth column, third column will be connected with seventh column and fourth column will be connected with eighth column. No other form of connection exists so total 4 connected components are there.

So, option (B) is correct.

Test: Graph - 2 - Question 15

If we want to search any name in the phone directory , which is the most efficient data structure?

Detailed Solution for Test: Graph - 2 - Question 15

In BST and balanced BST searching takes time in order of mlogn , where m is the maximum string length and n is the number of strings in tree . But searching in Trie will take O(m) time.
Hence , option C is the correct answer.

Test: Graph - 2 - Question 16

Consider a directed graph with n vertices and m edges such that all edges have same edge weights. Find the complexity of the best known algorithm to compute the minimum spanning tree of the graph?

Detailed Solution for Test: Graph - 2 - Question 16

It’s a special case in which all edge weights are equal, so dfs would work and resultant depth first tree would be the spanning tree. So the answer would be O(m+n).

Test: Graph - 2 - Question 17

Which of the following according to you is incorrect?

Detailed Solution for Test: Graph - 2 - Question 17

Both the hashing and the trie provides searching in the linear time. But trie requires extra space for storage and it is collision free. And trie allows finding all the strings with same prefix, so it is also called prefix tree.
Hence, option B is the correct option.

Test: Graph - 2 - Question 18

Trie is also known as _____.

Detailed Solution for Test: Graph - 2 - Question 18

Trie is also known as Digital tree.
Hence , option D is the correct answer.

Test: Graph - 2 - Question 19

What is the worst case efficiency for a path compression algorithm?

Detailed Solution for Test: Graph - 2 - Question 19

The worst case efficiency for a path compression algorithm is mathematically found to be O(M log N).
Hence, option A is correct.

Test: Graph - 2 - Question 20

In an undirected connected planar graph G, there are eight vertices and five faces. The number of edges in G is _________.

Detailed Solution for Test: Graph - 2 - Question 20

By using Euler’s theorem, the number of regions = e – v + 2
R = e – v + 2
5 = e – 8 + 2 = e-6
e = 5+6 = 11

Information about Test: Graph - 2 Page
In this test you can find the Exam questions for Test: Graph - 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Graph - 2, EduRev gives you an ample number of Online tests for practice

Top Courses for Computer Science Engineering (CSE)

Download as PDF

Top Courses for Computer Science Engineering (CSE)