Question: prettyprinter final output pretty printer code need to printer the tree more compact. inline with left root with left child snd align ( ) (a



(a (b d e ) (c ( (f (g O h ) " ( ) ) (a (bd e ) (co (f (g() . h ) ( ) ) ). private static String prettyPrint (BTree tree, String indentation) String result = indentation; if (tree == null) // empty tree (stops the recursion) { result += "/"; ) else if (tree. depth() == 0) // depth=0 stops the recursion also { result += tree.getElement(); } else 3 1 result += "1" + tree.getElement() + "n"; result += indentation + prettyPrint( tree.getLeftTree(), indentation+" result += prettyPrint tree.getRightTree, indentation+" result += indentation + ""; 3 4 } 5 6 7 return result; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
