Question
JAVA - Please complete the method compareBTrees() below: /* */ import binarytree.*; /** A program that tests the addStringBTrees() and addIntegerBTrees() methods. */ public class
JAVA - Please complete the method compareBTrees() below:
/*
*/
import binarytree.*;
/** A program that tests the addStringBTrees() and addIntegerBTrees() methods. */ public class CompareBTrees { /** Return a binary tree that is the node-by-node comparison of the two input trees.
The comparison of two empty trees is the empty tree.
The comparison of an empty tree and a non-empty tree is the empty tree.
The comparison of two non-empty trees, btree1 and btree2, is a tree whose root data element is a boolean holding the value btree1.root().equals(btree2.root())
The comparison of two non-empty binary trees is defined recursively using the above three cases.
Another way to describe the result tree is that a node of the result tree holds true if both input trees have that node and their contents are equal, and a node of the result tree holds false if both input trees have that node and their contents are not equal. So the result tree has nodes only at those positions where both input trees have a node. You might say that the result tree has the shape of the "intersection" of the two input trees (compare this with the AddBTrees.addStringBTrees() and AddBTrees.addIntegerBTrees() methods). */ public static
}
// Simple test case for compareBTrees(). public static void main(String[] args) { BTree
BTree
BTree
System.out.println( btree1 ); System.out.println( btree2 ); System.out.println( btree3 ); BTree2dot.btree2dot(btree1, "btree1"); BTree2png.btree2png("btree1"); BTree2dot.btree2dot(btree2, "btree2"); BTree2png.btree2png("btree2"); BTree2dot.btree2dot(btree3, "btree3"); BTree2png.btree2png("btree3"); } }
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