Here is a JUnit method Anna used to test removing the root. It kept reporting failure, but Anna could see nothing wrong with remove()’s implementation. After a frustrating hour of trying to solve the problem, Anna was floored when Opal walked by and pointed immediately to the mistake. What did Opal see?

```
public void testRemoveRoot(){
BinaryTreeNode root = tree3.root();
integer target = root.element();
// remove target from tree3 and the list of elements
// we expect to see in tree3
expectedTree3List.remove( target );
tree3.remove( root );
assertTrue( !tree3.contains( target ) );
ToListVisitor treeVisitor = new ToListVisitor();
tree3.preOrderTraversal( treeVisitor );
assertTrue( expectedTree3List.equals( treeVisitor.list() ) );
}

```


The remove() method will pull a leaf node up to replace the value formerly in the root. Thus expectedTree3List and tre3Visitor.list() will have the same elements, but not necessarily in the same order. Consequently the last assertTrue() will report false.

Computer Science & Information Technology

You might also like to view...

The default speed for transition effects in Impress is Slow

Indicate whether the statement is true or false

Computer Science & Information Technology

The text editor Notepad comes with Apple OS X.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Determining if fair use applies to a work depends solely on the purpose of its use.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

One of your coworkers says, “Mission statements are nice, but they really don’t change things down here where the work gets done.” How would you reply?

What will be an ideal response?

Computer Science & Information Technology