Question
JAVA - Please complete the addStringBTrees() and addIntegerBTrees() methods below: /* */ import binarytree.*; /** A program that tests the addStringBTrees() and addIntegerBTrees() methods. */
JAVA - Please complete the addStringBTrees() and addIntegerBTrees() methods below:
/*
*/
import binarytree.*;
/** A program that tests the addStringBTrees() and addIntegerBTrees() methods. */ public class AddBTrees { /** Return a binary tree that is the node-by-node "sum" of the two input trees of type String.
The sum of two empty trees is the empty tree.
The sum of an empty tree and a non-empty tree is the non-empty tree.
The sum of two non-empty trees is a tree whose root data element is the sum of the root data elements from the two trees.
The sum of two non-empty binary trees is defined recursively using the above three cases.
Notice that the result tree has a node at any position where at least one of the two input trees has a node. You might say that the result tree has the shape of the "union" of the two input trees (compare this with the CompareBTrees.compareBTrees() method). */ public static BTreeAbstract
}
/** Return a binary tree that is the node-by-node "sum" of the two input trees of type Integer. This method is defined similarly to addStringBTrees(). */ // Define addIntegerBTrees()...
// Simple test cases for addStringBTrees() and addIntegerBTrees(). 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");
BTree
BTree
BTree
System.out.println( btree4 ); System.out.println( btree5 ); System.out.println( btree6 ); BTree2dot.btree2dot(btree4, "btree4"); BTree2png.btree2png("btree4"); BTree2dot.btree2dot(btree5, "btree5"); BTree2png.btree2png("btree5"); BTree2dot.btree2dot(btree6, "btree6"); BTree2png.btree2png("btree6"); } }
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