Sunday, 15 August 2010

java - Recursively find height of tree/ deepest node -



java - Recursively find height of tree/ deepest node -

can help walk me through finding height of tree using recursive depth first search? i.e find deepest branch node? thanks

pseudocode:

dfs( v ): 1. visited[ v ] = true 2. max_child_depth = 0 3. each u s.t. there's border (v,u)         if not visited[ u ]         then max_child_depth = max( max_child_depth, dfs( u )) 4. return max_child_depth + 1

java algorithm tree

No comments:

Post a Comment