Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 B
A tree has the vertices D, J, K, M, O, R, U, W, Z and the edges K–Z, K–M, Z–D, M–U, D–J, D–W, D–O, K–R. 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. W
- C. Z
- D. R
Correct answer: C. Z
Removing Z leaves components of at most 4 vertices, while every other vertex leaves a component bigger than n/2. The highest-degree vertex D 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
- A tree has vertices with values in brackets: A[-2], U[8], Y[5], G[0], Z[-3], V[6], T[1], J[-2]. The edges are A–U, U–Y, Y–G, G–Z, A–V…
- A tree has vertices with values in brackets: O[1], Y[4], S[5], A[2], U[2], L[6]. The edges are O–Y, Y–S, Y–A, O–U, O–L. A path is any…
- The directed acyclic graph has the vertices D, O, R, T, U, Y and the arcs Y→O, T→O, O→R, Y→T, Y→D, Y→R, T→R, T→U. How many distinct…
- A connected undirected graph has the vertices B, F, M, O, Z and weighted edges (weights in brackets): O–M (16), F–Z (14), B–M (7), O–B…
- An undirected graph has the vertices C, J, L, Q, W and the edges W–L, J–C, L–C, J–Q, Q–L, W–C, W–J, W–Q. How many simple cycles does it…
- A tree on the vertices B, E, G, S, W has the arcs W→E, S→E, B→W, W→G (each undirected edge is directed as shown). You may reverse the…