Ask Question

Write the recursive function count; it is passed balanced binary (any binary tree, not necessarily a binary search tree) and a value as arguments. It returns the number of times the values is in the tree. In the binary tree below, count (tree, 1) returns 1, count (tree, 2) returns 2, count (tree, 3) returns 4.

+1
Answers (1)
  1. 20 August, 00:40
    0
    Python code:

    def max_depth_util (root, val, level):

    if root is None:

    return 0;

    if root. data = = val:

    return level

    if root. left is not None or root. right is not None:

    return max_depth_util (root. left, val, level + 1) + max_depth_util (root. right, val, level + 1)

    return 0;

    def max_depth (root, val):

    return max_depth_util (root, val, 1)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write the recursive function count; it is passed balanced binary (any binary tree, not necessarily a binary search tree) and a value as ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers