Data Structures & AlgorithmsModerateGATE CS · ICPC regional
A tree has the vertices E, F, G, I, K, N, Y and the edges G–F, G–N, F–E, N–K, K–Y, K–I. A centroid is a vertex whose removal leaves no connected component with more than n/2 vertices. Which vertex is the centroid?
- A. K
- B. I
- C. N
- D. G
Correct answer: C. N
Removing N leaves components of at most 3 vertices, while every other vertex leaves a component bigger than n/2. The highest-degree vertex K is a common wrong guess.
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
- An undirected graph on 7 vertices has the edges J–P, J–O, J–U, P–O, P–B, P–U, O–S, O–A, O–U, A–U. How many simple paths (no repeated…
- Grid with 4 rows and 4 columns (top to bottom). A cell marked G is a gate; '.' is a normal cell: .G.. G.G. .... .... Each step, which is a…
- A flow network has source S and sink T, with directed arcs and capacities in brackets: S→E (6), S→A (2), S→C (2), S→T (6), E→T (2), D→A…
- A directed graph has the vertices D, E, H, I, K, N, O and the arcs N→E, N→D, K→N, K→O, E→O, I→N, I→E, H→K, O→N. How many strongly…
- A tree has the vertices A, C, M, R, V, Y, Z and the edges C–M, M–A, C–R, A–Y, A–V, R–Z. A set D dominates the tree if every vertex is in D…
- A directed graph with no directed cycles has arcs u→v (weight) : F→S (3), F→N (0), F→C (8), G→X (2), G→C (4), S→X (3), N→X (1), N→C (6)…