Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
A tree has the vertices F, H, L, N, O, T, U, V, X and the edges L–O, O–F, L–N, F–H, L–V, O–X, H–U, F–T. A centroid is a vertex whose removal leaves no connected component with more than n/2 vertices. Which vertex is the centroid?
- A. O
- B. T
- C. U
- D. N
Correct answer: A. O
Removing O leaves components of at most 4 vertices, while every other vertex leaves a component bigger than n/2. The highest-degree vertex L 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 has the vertices E, F, G, I, Z and the edges G–I, G–Z, G–F, E–F, I–Z, I–F, Z–F. A walk may repeat vertices and edges…
- An undirected graph on 5 vertices has the edges D–E, D–J, D–T, E–H, E–J, E–T, H–T, J–T. How many simple paths (no repeated vertex) go from…
- The directed acyclic graph has the vertices D, F, G, I, J, O, Z and the arcs J→D, I→G, G→F, I→Z, I→D, F→D, G→D. How many distinct directed…
- A connected undirected graph has the vertices D, E, O, P, W and weighted edges (weights in brackets): D–P (3), E–P (19), D–E (8), P–O (5)…
- A bipartite graph has left side P1, P2, P3 and right side Q1, Q2, Q3, Q4, Q5, with edges P3–Q1, P1–Q2, P3–Q2, P3–Q4, P1–Q5, P2–Q4, P1–Q1…
- A grid has 4 rows and 3 columns with these values (top to bottom): 944 176 815 649 A path moves between side-adjacent cells (up, down…