Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Below you are given the implementation of a class named bt_node , which represents a node in a binary tree data structure. Complete the implementation
Below you are given the implementation of a class named bt_node , which represents a node in a binary tree data structure. Complete the implementation of the bt_node.has_children() and bt_node.get_children() methods according to the following specifications: node.bt_node.has_children() should return True if the provided binary tree node object, node , has at least one child and False otherwise. node.bt_node.get_children() should return a list of the immediate children of the given node. That is, if the provided node has no children, this method should return an empty list. Clearly, when the given node has both children, this method will return a list of length 2. YOU MUST WRITE YOUR CODE IN THE FOLLOWING CODE CELL : class bt_node: Defines a node in the binary tree def __init_( self, value, left=None, right=None ): self.value = value self.left = left self.right = right def has_children( self ): Returns True if this node has at least one child # YOUR CODE HERE raise Not ImplementedError() def get_children( self ): Returns a list of child nodes # YOUR CODE HERE raise Not ImplementedError() def eq__( self, other ): return self.value == other.value def __it__( self, other ): def __it__( self, other ): To enable sorting return self.value >> TEST 1 PASSED >> TEST 2 PASSED >> TEST 3 PASSED >> TEST 1 PASSED >> TEST 2 PASSED >> TEST 3 PASSED >> TEST PASSED >> TEST PASSED >> TEST PASSED >> TEST PASSED >> TEST PASSED >> TEST PASSED >> TEST PASSED >> TEST PASSED
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started