Question

Network Structures

1. The length of a path in a simple graph is the number of edges on it. The distance between two nodes of a simple graph is the length of the shortest path connecting them. The diameter of a graph is the maximum distance between a pair of nodes. Let v1 , . . . , vnbe all the nodes of a graph G, and let distG(vi,  vj ) be the distance between viand vjin this graph G. Then the average distance between nodes of G is the number

distG(vi, j) Notice that there are (2) pairs of nodes vi and Uj such that l < i < n. (a) Consider a graph that consists of a clique K of i nodes and a path of 10 edges ww11 where wi e Ki while wj 또 Ki for J > 1 . What is the diameter of this graph? graphs is less than 2 graph whose diameter is greater than and the average distance between nodes average distance betw (b) Generalize the example of (a) to show that for any integer > 0 there exists a is less than 2

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The distance between the two nodes d(x,y) x and y in the tree is the number of edges in the shortest path between them , The longest path in tree T is either in one of the subtrees of the root x, or it is a path from a leaf of one subtree to x, and a path from x to a leaf in the other subtree, And the diameter is recursively computed as,

diameter(x) = max(diameter(leftsubtree(x)), diameter(rightsubtree(x)), height(leftsubtree(x)) + height(rightsubtree(x)) + 2).

Hence the pseudocode of the recursive algorithm that returns both the diameter and height of the tree rooted at a given node x is as given below :

(int,int) = Diameter(x) { // It returns the (diameter(x) , height(x))

if (x=NIL)

return(-1,-1)

(p,q) = Diameter(leftsub(x))

(r,s) = Diameter(rightsub(x))

v = 1 + max(q,r)

u = max(p,r,q+s+2)

return(u,v) }

If the time complexity is given as T(n) for the tree T having n nodes , The recurrence relation is derived as ,

T(n) <= max {T(i) , T(n − i − 1) : 0 <= i <= n − 1} + c, T(0) = c.

By using induction , T(n) <= cn , Hence T(n) ∈ O(n) .

Add a comment
Know the answer?
Add Answer to:
Network Structures 1. The length of a path in a simple graph is the number of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT