Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is my code. I got error messege from the test. @Test ( timeout = TIMEOUT.)

ID: 3888591 • Letter: T

Question

This is my code.

I got error messege from the test.

@Test ( timeout = TIMEOUT.) public void testLeavesDescending) LinkedList

Explanation / Answer

public List listLeavesDescending() { List list = new ArrayList(); Queue> queue = new LinkedList>(); BSTNode tmp = root; if (root == null) { return list; } else { queue.add(root); listLeavesDescendingHelper(list, queue, tmp); return list; } } private void listLeavesDescendingHelper(List list, Queue> queue, BSTNode node) { if (queue.isEmpty()) { return; } while (queue.size() > 0) { BSTNode tmp = queue.poll(); if (tmp.getLeft() != null && tmp.getRight() != null) { list.add(node.getData()); } if (tmp.getLeft() != null) { queue.add(tmp.getLeft()); } if (tmp.getRight() != null) { queue.add(tmp.getRight()); } } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote