Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a. Write a method in BinaryNode.java file to count number of leaf nodes in a Binary Tree. (5 points) b. You want to be
a. Write a method in BinaryNode.java file to count number of leaf nodes in a Binary Tree. (5 points) b. You want to be able to get the minimum and maximum values from a Binary Search Tree. Rather than add getMin() and getMax() methods to the BinarySearchTree, you will create a BSTMinMax class that extends BinarySearch Tree. Use the UML diagram below to implement the BSTMinMAXclass. You do not need to alter the BinarySearchTree or BinaryNode classes in the ds package. c. You may override BinarySearch Tree methods or add additional private attributes and methods as needed to BSTMin. d. Your getMin() and getMax() methods must work as efficiently as possible, that is, each method should not attempt a full traversal of the tree. e. Write at least 2-unit tests in BSTMinMaxTest to test your implementation. < > Comparable + compareTo(o: E) E::Comparable BinarySearch Tree # root: BinaryNode # size: int + BinarySearch Tree(initialValue: T) + toString(): String + size(): int + search(target: T): boolean + insert(value: T) void BinaryNode + BinaryNode(value: T) + toString(): String + getValue(): T + setValue(value: T) + getLeft(): BinaryNode + setLeft(left: BinaryNode ) + getRight(): BinaryNode + setRight(right: BinaryNode ) T::Comparable BSTMinMax + BSTMinMax(initialValue: T) + getMin(): T Recall that T::Comparable indicates that the type parameter T in the BinarySearchTree class will use type Comparable . Your BSTMin class signature should be public class BSTMin extends BinarySearch Tree
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started