Write a tostring method for a binary tree of


Write a toString method for a binary tree of integers. The method should return "empty" for an empty tree. For a leaf node, it should return the data in the node as a string. For a branch node, it should return a parenthesized String that has three elements separated by commas: the data at the root, a string representation of the left subtree, and then a string representation of the right subtree. For example, if a variable t refers to reference tree #2, then the call t.toString() should return the following String (without the surrounding quotes):

1111_21bf6f74-fd5e-4a07-8b30-330533bab9c7.png

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Write a tostring method for a binary tree of
Reference No:- TGS02201340

Expected delivery within 24 Hours