Ask Question
9 March, 04:42

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.

+3
Answers (1)
  1. 9 March, 08:18
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers