9 Give O N Time Algorithm Computing Depth Nodes Tree T Arbitrary Tree N Number Nodes T 7 P Q37079906

9. Give an O(n)-time algorithm for computing the depth of all the nodes of a tree T (arbitrary tree), where n is the number o9. Give an O(n)-time algorithm for computing the depth of all the nodes of a tree T (arbitrary tree), where n is the number of nodes of T. (7 points) Show transcribed image text 9. Give an O(n)-time algorithm for computing the depth of all the nodes of a tree T (arbitrary tree), where n is the number of nodes of T. (7 points)


Solution


Function calculateHeight(root)

BEGIN

         // I the tree is empty

         If root

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.