Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions