📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    Complete the recursive search function for a Binary

    Search Tree (BST). class Node:     def __init__(self, data):         self.data = data         self.left = None         self.right = None def search(root, key):     if root is None or root.data == key:         return root     if key < root.data:         _________ # Line to complete (search left subtree)     else:         _________ # Line to complete (search right subtree)
    A return search(root.left, key) ; return search(root.right, key) Correct Answer Incorrect Answer
    B search(root.left, key) ; search(root.right, key) Correct Answer Incorrect Answer
    C return root.left ; return root.right Correct Answer Incorrect Answer
    D return search(root.right, key) ; return search(root.left, key) Correct Answer Incorrect Answer
    E return key ; return key Correct Answer Incorrect Answer

    Solution

    The correct answer is A

    Practice Next
    More IT Operating System Questions
    ask-question