sgraph - Graph Algorithms - Sample Solutions 1. Broadcast...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Graph Algorithms - Sample Solutions 1. Broadcast Times for a Tree Problem Let T be a rooted binary tree whose edges are given positive real weights, representing message delay times . For a node x T , define the broadcast time for x to be the maximum over y T of the weighted dis- tance in T between x and y . (In other words, the broadcast time is the time before a message originatin at x is received by every other processor y .) Give an efficient algorithm to compute all the broadcast times for nodes in T simultaneously. Solution This solution basically performs two level traversals of the tree. One upward from the leaves keeping track of the largest broadcast up times and one down- ward adding on the broadcast down part of a path. Associate with each edge, ( u, v ) , a variable d [( u, v )] that will hold the broadcast time first from the farthest node in the direction of v (the child), then from the farthest in the direction of u . Starting at the leaves and working in levels toward the root, set d [( u, v )] = max j C ( v ) ( d [( v, j )] + w [( u, v )]) All d [( u, v )] will then hold the longest broadcast time from u to a vertex in the subtree rooted at v . Then from the root down to the leaves set the broadcast time of vertex i to be the farthest time either down one of its children or up through its parent, b [ i ] = max j N ( i ) ( d [( i, j )]) Also, set for i s children, j C ( i ) , broadcast times on the edges now reflecting upward broadcasts, d [( i, j )] = max k N ( i ) ,k 6 = j ( d [( i, k )]) + w [( i, j )] This algorithm makes two passes over the n- 1 edges in the tree and performs work linear in the degree of each vertex, d . The instances in the problem are stated to be binary trees, so d O (1) and the total time is O ( n ) . (This can be shown to be O ( n ) for a tree with any degrees by amortizing the work over the edges, which are set twice and examined three times each). We can prove the correctness by looking at the content of the variables d [( u, v )] ....
View Full Document

Page1 / 4

sgraph - Graph Algorithms - Sample Solutions 1. Broadcast...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online