Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be done in java: LIBRARIES available to USE: java.util.linkedlist, java.util.stack, java.util.queue Objective: The goal of this assignment is to practice the use of binary

Must be done in java: LIBRARIES available to USE: java.util.linkedlist, java.util.stack, java.util.queue

Objective: The goal of this assignment is to practice the use of binary search trees.

Assignment: Write several recursive methods related to trees:

-a method that, given a binary search tree, returns its smallest element;

-a method that, given a binary search tree, returns its largest element;

-a method that, given a binary search tree, returns the total number of elements in the tree;

-a method that, given a binary search tree, returns its height;

-a method that, given an element and a binary search tree, checks whether this element belongs to this tree;

-a method that, given an element and a binary search tree, adds this element to the tree.

Main idea. For example, to find a given element in a given tree, we do the following. First, we check whether the tree is empty. If the tree is empty, then the given element is not there, otherwise we compare the given element with the root of the tree:

-if the element is equal to the root, we return "true";

-if the element is smaller than the root, we search in the left subtree;

-if the element is larger than the root, we search in the right subtree.

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

Explain objectives, inputs and outputs of fixed asset management.

Answered: 1 week ago

Question

3. Existing organizations and programs constrain behavior.

Answered: 1 week ago