Question

Write a client method that returns a count of the number of nodes in a binary search tree that contain scores less than or equal to a passed-in argument (parameter) value. The method header is:

int countLowerScores (BinarySearchTree tree, int maxValue)

The BinarySearchTree contains these methods in the picture.public class BinarySearchTreecT> implements BSTInterfacecT> //reference to the root of this BST public BSTNode<T> root; publi

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:

1) Write a client method that returns a count of the number of nodes in a binary search tree that contains a value less than or equal
to the argument value. The signature of the method is
int countLess (BinarySearchTree<Golfer> tree, Golfer maxValue)
  
int countLess (BinarySearchTree<Golfer> tree, Golfer maxValue)
{
int tree_size,i;
int number_of_nodes = 0;
tree_size = tree.reset(BinarySearchTree.INORDER);
for (i = 1; i <= tree_size; i++)
{
if ((tree.getNext(BinarySearchTree.INORDER).compareTo(maxValue))<= 0)
number_of_nodes = number_of_nodes + 1;
}
return number_of_nodes;
}

Add a comment
Know the answer?
Add Answer to:
Write a client method that returns a count of the number of nodes in a binary...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT