85.0k views
3 votes
Recall that within our BinarySearchTree class the root variable is of type BSTNode. A BSTNode object has three attributes: info of class T, left of class BSTNode, and right of class BSTNode, Following is the implementation of the isEmpty method: public boolean isEmpty() // Returns true if this BST is empty; otherwise, returns false.

{
return (root == null);
}
A. True
B. False

User Jhilgeman
by
6.4k points

1 Answer

3 votes

Answer:

False ( A )

Step-by-step explanation:

The implementation is incorrect hence the return would be false and this is because : root.left is supposed to be NULL, root.right is supposed to be NULL and when these conditions are met then the Binary tree would be empty.

The condition for the above statement would be represented as

if( root.left = = null && root.right == null &&root.info == null)

return true;

else

return false;

User Assaf Neufeld
by
7.3k points