Data Structures & AlgorithmsModerateCodeforces Div2 C · ICPC regional
A tree has these edges (given as parent→child; ignore the direction): 82→41, 54→80, 65→82, 80→95, 38→54, 80→67, 67→65. The eccentricity of a node is its largest distance, in edges, to any other node. Which node is the centre, the unique node of minimum eccentricity?
- A. 67
- B. 80
- C. 65
- D. 38
Correct answer: A. 67
The centre is the middle vertex of a diameter path (here diameter 6 edges, middle node 67); its eccentricity is the smallest. The node one step off the middle, the highest-degree node or the root are traps.
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 these edges (given as parent→child; ignore the direction): 78→50, 50→80, 40→98, 78→30, 97→78, 80→73, 40→97. The eccentricity of…
- A tree has these edges (given as parent→child; ignore the direction): 38→54, 81→67, 81→51, 31→81, 72→53, 51→62, 51→38, 72→31. The…
- A tree has these edges (given as parent→child; ignore the direction): 92→25, 93→98, 27→54, 27→73, 98→27, 98→40, 73→81, 92→57, 27→92. The…
- A tree has these edges (given as parent→child; ignore the direction): 97→22, 53→38, 38→28, 81→44, 28→35, 22→53, 22→2, 22→46, 53→81, 35→54…
- A tree has these edges (given as parent→child; ignore the direction): 13→32, 13→58, 58→2, 31→13, 5→99, 31→5, 2→25, 2→87, 5→14, 2→52. The…
- A tree has these edges (given as parent→child; ignore the direction): 86→81, 45→86, 14→68, 38→14, 38→47, 47→75, 38→29, 38→43, 65→38…