Question: Suppose you work for a company, iPilgrim.com, whose n employees are organized in a tree T, so that each node is associated with an employee

Suppose you work for a company, iPilgrim.com, whose n employees are organized in a tree T, so that each node is associated with an employee and each employee is considered a supervisor for all the employees (including themselves) in his or her subtree in T, as in the previous exercise. Furthermore, suppose that communication in iPilgrim is done the “old fashioned” way, where, for an employee, x, to send a message to an employee, y, x must route this message up to a lowest-level common supervisor of x and y, who then routes this message down to y. The problem is to design an algorithm for finding the length of a longest route that any message must travel in iPilgrim.com. That is, for any node v in T, let dv denote the depth of v in T. The distance between two nodes v and w in T is dv + dω − 2du, where u is the LCA u of v and w (as defined in the previous exercise). The diameter of T is the maximum distance between two nodes in T. Thus, the length of a longest route that any message must travel in iPilgrim.com is equal to the diameter of T. 

Describe an efficient algorithm for finding the diameter of T. What is the running time of your method?

Step by Step Solution

3.33 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Let duv be the diameter of T First observe that both u and v are tree leaves if not we can find a path of higher length only by considering one of us ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures Algorithms Questions!