Data Structures & AlgorithmsVery hardGoogle · Trees

A weighted tree has edges A-B 3, A-C 4, B-D 5, B-E 2, C-F 6, F-G 1, F-H 7, E-I 8, D-J 2, H-K 3. What is its diameter (the greatest path length between any two vertices)?

  1. A. 30
  2. B. 33
  3. C. 28
  4. D. 35

Correct answer: B. 33

The longest path is K-H-F-C-A-B-E-I: 3 + 7 + 6 + 4 + 3 + 2 + 8 = 33; the J-to-K path is shorter at 30.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic