Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please refer to the TreeNode.java and MyTree.java and implement the method as specified below: public int countAboveBenchmark (MyTree mt, int val) COPYRIGHT COP RIGHT This

image text in transcribed

Please refer to the TreeNode.java and MyTree.java and implement the method as specified below: public int countAboveBenchmark (MyTree mt, int val) COPYRIGHT COP RIGHT This method takes a MyTree and a benchmark value (val) as parameters and count and return howmany numbers in the tree are greater than or equals to the benchmark value. COPYRIGHT continuare For example, given the following tree, calling : nchmark de stand countAboveBenchmark(mt, 10) should return 2, because there are two numbers: 15 and 24 are greater than 10. COPYRIGHT -9 LOPAEHT | 15 | ZOPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT -12 | 24 COPYRIGHT COPYRIGHT public class TreeNode{ 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 getLeft0{ 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 class MyTree { private TreeNode root; public MyTree() { root = null; } public void add(int data) { //omitted } public TreeNode getRoot({ return root; } } GHT COPY PYRIGHT Please refer to the TreeNode.java and MyTree.java and implement the method as specified below: public int countAboveBenchmark (MyTree mt, int val) COPYRIGHT COP RIGHT This method takes a MyTree and a benchmark value (val) as parameters and count and return howmany numbers in the tree are greater than or equals to the benchmark value. COPYRIGHT continuare For example, given the following tree, calling : nchmark de stand countAboveBenchmark(mt, 10) should return 2, because there are two numbers: 15 and 24 are greater than 10. COPYRIGHT -9 LOPAEHT | 15 | ZOPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT COPYRIGHT -12 | 24 COPYRIGHT COPYRIGHT public class TreeNode{ 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 getLeft0{ 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 class MyTree { private TreeNode root; public MyTree() { root = null; } public void add(int data) { //omitted } public TreeNode getRoot({ return root; } } GHT COPY PYRIGHT

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

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions