|
-
June 2nd, 2006, 08:51 PM
#1
recursive algorithm for shortest path in binary trees
Suppose we are given a binary tree T of 'n' nodes and a pointer to some node p. How do we compute the shortest path(number of edges) from node 'p' to all other nodes of the binary tree. We could use an array to store the distances.
We are also given another array D[1:n] which stores the depth of each node from the root. Depth of root = 0, depth of the next level of nodes =1 and so on.
Note: the code should be recursive.
I have been thinking over this for a long time. Does anyone know how to approach this.
-sweta Venkatesh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|