GATE CS 2016, set 2 · Question 51 · Programming and Data Structures · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer
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?
- (A) Θ(n²)
- (B) Θ(n+m)
- (C) Θ(m²)
- (D) Θ(n⁴)
Answer
Answer (B)
Answer from the official GATE CS 2016 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes