Ask Question
29 June, 08:57

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. 29 June, 12:49
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers