Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Implement remove and printReverse method *Implement display method to display the tree structure public class MyTree{ private TreeNode root; public MyTree(){ root=null; } public void

*Implement remove and printReverse method *Implement display method to display the tree structure

public class MyTree{

private TreeNode root; public MyTree(){ root=null; } public void remove(int data){ //implement this method to remove a node with the same data value } 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()

given : TreeNode.java

public class TreeNode implements Comparable{

private int data; private TreeNode left; private TreeNode right;

public TreeNode(int data){ this.data=data; left=right=null; }

public int getData(){ return data; } public TreeNode getLeft(){ return left; } public TreeNode getRight(){ return right; } public void setData(int data){ this.data = data; } public void setLeft(TreeNode left){ this.left = left; } public void setRight(TreeNode right){ this.right = right; } public int compareTo(TreeNode node){ return data-node.getData(); } }

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

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions