Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class MyTree{ private TreeNode root; public MyTree(){ root=null; } public void remove(int data){ if (root == null) return false; else{ if (root.getValue() == value)

public class MyTree{

private TreeNode root; public MyTree(){ root=null; } public void remove(int data){ if (root == null) return false; else{ if (root.getValue() == value) {

BSTNode auxRoot = new BSTNode(0);

auxRoot.setLeftChild(root);

boolean result = root.remove(value, auxRoot);

root = auxRoot.getLeft();

return result;

} else {

return root.remove(value, null); } } public void printReverse(){ //implement this method to print data in descending order } public void display(){ //implement to display the tree structure } public boolean isEmpty(){ return root==null;} public int size(){ return sizeHelper(root); } private int sizeHelper(TreeNode node){ if(node==null) return 0; else return 1+sizeHelper(node.getLeft())+sizeHelper(node.getRight()); } public boolean search(int data){ return searchHelper(root, data); } private boolean searchHelper(TreeNode node, int data){ if(node==null) return false; if(node.getData()==data) return true; else if(node.getData()

Question: I'm not sure how to implement the printReverse method and display the tree form.

Could you show me the methods please? Thanks!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Presentation Aids Practicing Your Speech?

Answered: 1 week ago