12.12 NVCC Lab: Count values in a tree Please refer to the TreeNode.java and MyTree.java and implement the method as specified below: public int countAboveBenchmark(MyTree mt, int val) This method takes a MyTree and a benchmark value (val) as parameters and count and return how many numbers in the tree are greater than or equals to the benchmark value. For example, given the following tree, [9] , [12] [15] [24] [3] / [0] calling: countAbove Benchmark(mt, 13) should return 2, because there are two numbers: 15 and 24 are greater than 13 =======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;B public TreeNode getLeft () { } return left; public TreeNode getRight () { return right;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help with this Java problem to output as it's explained in this image below:

 

This part continues after the given image below: 

=======TreeNode.java======= public class TreeNode implements Comparable<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 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(); } } =========MyTree.java======= public class MyTree{ private TreeNode root; public MyTree(){ root=null; } public TreeNode getRoot(){ return root; } //all other methods are omitted }

 

public class Main{
   public int countAboveBenchmark(MyTree mt, int val){
      //TO DO: count and return how many numbers in the tree are greater than  or equals to the benchmark value.
   }

}

12.12 NVCC Lab: Count values in a tree
Please refer to the TreeNode.java and MyTree.java and implement the method as specified below:
public int countAboveBenchmark(MyTree mt, int val)
This method takes a MyTree and a benchmark value (val) as parameters and count and return how many numbers in the tree are greater
than or equals to the benchmark value.
For example, given the following tree,
[9]
,
[12]
[15]
[24]
[3]
/
[0]
calling: countAbove Benchmark(mt, 13) should return 2, because there are two numbers: 15 and 24 are greater than 13
=======TreeNode.java=======
public class TreeNode implements Comparable<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;B
public TreeNode getLeft () {
}
return left;
public TreeNode getRight () {
return right;
Transcribed Image Text:12.12 NVCC Lab: Count values in a tree Please refer to the TreeNode.java and MyTree.java and implement the method as specified below: public int countAboveBenchmark(MyTree mt, int val) This method takes a MyTree and a benchmark value (val) as parameters and count and return how many numbers in the tree are greater than or equals to the benchmark value. For example, given the following tree, [9] , [12] [15] [24] [3] / [0] calling: countAbove Benchmark(mt, 13) should return 2, because there are two numbers: 15 and 24 are greater than 13 =======TreeNode.java======= public class TreeNode implements Comparable<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;B public TreeNode getLeft () { } return left; public TreeNode getRight () { return right;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education