Question: JAVA - please complete the below method ConcatenateLeaves() /* */ import binarytree.*; /** A program that tests the concatenateLeaves() method. */ public class ConcatenateLeaves {

JAVA - please complete the below method ConcatenateLeaves()

/*

*/

import binarytree.*;

/** A program that tests the concatenateLeaves() method. */ public class ConcatenateLeaves { /** Return a string that is the concatenation of the leaves, from the input binary tree, going from left to right.

How does this compare with an in-order, or pre-order, or post-order traversal of the binary tree? */ public static String concatenateLeaves(BTree btree) { String result = "";

return result; }

// A simple test case for concatenateLeaves(). public static void main(String[] args) { BTree btree = new BTreeLinked<>("#", new BTreeLinked<>("#", new BTreeLinked<>("mary"), new BTreeLinked<>("had")), new BTreeLinked<>("#", new BTreeLinked<>("a"), new BTreeLinked<>("#", new BTreeLinked<>("little"), new BTreeLinked<>("lamb"))));

String result = concatenateLeaves( btree );

System.out.println( btree ); System.out.println( result ); BTree2dot.btree2dot(btree, "btree"); BTree2png.btree2png("btree");

System.out.println( btree.preOrder() ); System.out.println( btree.inOrder() ); System.out.println( btree.postOrder() ); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!