Write a method called printLeaves that prints to System.out the leaves of a binary tree from right

Question:

Write a method called printLeaves that prints to System.out the leaves of a binary tree from right to left. More specifically, the leaves should be printed in the reverse order that they would be printed using any of the standard traversals. If the tree is empty, your method should produce the output "no leaves". For example, if a variable t refers to reference tree #2, the call of t.printLeaves(); should produce the following output:

leaves: 9 4 0

Reference Tree #2 2 Reference Tree #1 1 7. 4 4 Reference Tree #3 2 3 8. 9. 3. 1.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: