Data Structures & AlgorithmsHardProduct-company MCQ pattern
An undirected graph has edges 1–2, 2–3, 3–1, 3–4, 4–5, 5–6, 6–4, 6–7. How many articulation points (vertices whose removal disconnects the graph) does it have?
- A. 1
- B. 2
- C. 4
- D. 3
Correct answer: D. 3
Removing 3 cuts {1, 2} off; removing 4 cuts {1, 2, 3} from {5, 6, 7}; removing 6 isolates 7. Vertices inside the triangles (1, 2, 5) and the leaf 7 are not cut vertices. Missing 6 because it lies on a cycle gives 2.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- What is the time complexity of g(n)? python def g(n): if n <= 1: return for i in range(n): pass # O(1) g(n // 2) g(n // 2) g(n // 2)
- How many of these statements about DFS are correct? (i) In DFS of an undirected graph, every non-tree edge is a back edge (there are no…
- Keys are inserted into an empty BST in the order 45, 15, 79, 90, 10, 55, 12, 20, 50. What is the postorder traversal? python def insert(t…
- For the same kind of BST, what is the height (edges on the longest root-to-leaf path) after inserting 1, 2, 3, 4, 5, 6, 7 in order, versus…
- A max-heap is built with heapify on the array below (0-based, children 2i+1 and 2i+2). What is the resulting array? python def sift(a, i…
- From the max-heap [50, 30, 40, 10, 20, 35, 25], delete the maximum once. What is the array? python import heapq h = [-x for x in [50, 30…