Quiz On Graph Data Structure

Last Updated : 26 Dec, 2023

A Graph is a non-linear data structure consisting of vertices and edges. The vertices are sometimes also referred to as nodes and the edges are lines or arcs that connect any two nodes in the graph. More formally a Graph is composed of a set of vertices( V ) and a set of edges( E ). The graph is denoted by G(E, V).
More on Graph

Graph Data Structure Quiz

Graph Data Structure Quiz

Question 1

Which of the following ways can be used to represent a graph?

Cross

Adjacency List and Adjacency Matrix

Cross

Incidence Matrix
 

Tick

Adjacency List, Adjacency Matrix and Incidence Matrix

Cross

None of the above



Question 1-Explanation: 

Adjacency Matrix, Adjacency List and Incidence Matrix are used to represent a graph.

Question 2

For a given graph G having v vertices and e edges which is connected and has no cycles, which of the following statements is true?

Cross

v=e
 

Tick

v = e+1

Cross

v + 1 = e

Cross

v = e-1



Question 2-Explanation: 

For any connected graph with no cycles the equation holds true.

Question 3

Which of the following is true?
 

Cross

A graph may contain no edges and many vertices

Tick

A graph may contain many edges and one vertex

Cross

A graph may contain no edges and no vertices

Cross

A graph may contain no vertices and many edges



Question 3-Explanation: 

A graph must contain at least one vertex.

Question 4

Time Complexity of DFS is? (V – number of vertices, E – number of edges)

Tick

O(V + E)

Cross

O(V)

Cross

O(E)

Cross

O(V*E)



Question 4-Explanation: 

The Depth First Search explores every node once and every edge once (in worst case), so it’s time complexity is O(V + E).

Question 5

A person wants to visit some places. He starts from a vertex and then wants to visit every vertex till it finishes from one vertex, backtracks and then explore other vertex from same vertex. What algorithm he should use?

Tick

Depth First Search

Cross

Breadth First Search

Cross

Trim’s algorithm

Cross

Kruskal’s Algorithm



Question 5-Explanation: 

This is the definition of the Depth First Search. Exploring a node, then aggressively finding nodes till it is not able to find any node.

Question 6

A bridge cannot be a part of 

Tick

a simple cycle 

Cross

a tree

Cross

a clique with size>=3 whose every edge is a bridge

Cross

a graph which contains cycle



Question 6-Explanation: 

In a connected graph, a bridge is an edge whose removal disconnects the graph. In a cycle if we remove an edge, it will still be connected. So, bridge cannot be a part of cycle.

Question 7

Which of the following is the most commonly used data structure for implementing Dijkstra’s Algorithm?

Cross

Max priority queue

Cross

Stack

Cross

Circular queue

Tick

Min priority queue



Question 7-Explanation: 

Minimum priority queue is the most commonly used data structure for implementing Dijkstra’s Algorithm because the required operations to be performed in Dijkstra’s Algorithm match with specialty of a minimum priority queue.

Question 8

What is the time complexity of Dijkstra’s algorithm?

Cross

O(N)

Cross

O(N3)

Tick

O(N2)

Cross

O(logN)



Question 8-Explanation: 

Time complexity of Dijkstra’s algorithm is O(N2) because of the use of doubly nested for loops. It depends on how the table is manipulated.

Question 9

In most of the cases, topological sort starts from a node which has __________

Cross

Maximum Degree

Cross

Minimum Degree

Cross

Any degree

Tick

Zero Degree



Question 9-Explanation: 

Topological sort starts with a node which has zero degree. If multiple such nodes exists then it can start with any node.

Question 10

Topological sort can be implemented by?

Cross

Using Depth First Search

Cross

Using Breadth First Search

Tick

Using Depth and Breadth First Search

Cross

Using level ordered search



Question 10-Explanation: 

We can implement topological sort by both BFS and DFS. In BFS, we use queue as data structure and in DFS, we use Linked list (if recursive) or Stack (if not recursive) as data structure.

There are 10 questions to complete.


Share your thoughts in the comments

Similar Reads