Given:

            private BinaryNode remove(T data, BinaryNode node) {
              // This local variable will contain the new root of the subtree,
              // if the root needs to change.
              BinaryNode result = node;
    
              // If there's no more subtree to examine
              if (node == null) {
                  throw new ItemNotFoundException(data.toString());
              }
    
              // if value should be to the left of the root
              if (data.compareTo(node.getData()) < 0) {
                  node.setLeft(remove(data, node.getLeft()));
              }
              // if value should be to the right of the root
              else if (data.compareTo(node.getData()) > 0) {
                  node.setRight(remove(data, node.getRight()));
              }
              // If value is on the current node
              else {
                  // If there are two children
                  if (node.getLeft() != null && node.getRight() != null) {
                      T successorData = elementAt(findMin(node.getRight()));
                      result = remove(successorData, result);
                      result.setData(successorData);
                  }
                  // If there is only one child on the left
                  else if (node.getLeft() != null) {
                      result = node.getLeft();
                  }
                  // If a leaf or only one child on the right
                  else {
                      result = node.getRight();
                  }
              }
              return result;
          }
          
and in order 18, 20, 25, 29, 31, 34, 49, 50, 60, 74, 83, 84, 85, 87, 89, 92, 99
What would the following method call result in:
            remove(74, topNode)
          

Choices are:

  • A
    74 gets removed and 60 becomes left child of 84
  • B
    74 and 60 get removed
  • C
    74 gets removed it 60 moves up
  • D
    84 replaces 74
  • C
    • B
    • D
    • A

    There are no hints for this question.