X280: Binary Tree Check Value Exercise

Write a recursive function that returns true if there is a node in the given binary tree with the given value, and false otherwise. Note that this tree is not a Binary Search Tree.
Here are methods that you can use on the BinNode objects:

AخA
 
1
interface BinNode {
2
  public int value();
3
  public void setValue(int v);
4
  public BinNode left();
5
  public BinNode right();
6
  public boolean isLeaf();
7
}

Write the BTcheckval function below:

Your Answer:

x
 
1
public boolean BTcheckval(BinNode root, int value)
2
{
3
    
4
}
5
Reset

Feedback

Your feedback will appear here when you check your answer.