# Compare the performance of two binary search trees as more objects are added to them. Initially, one

Compare the performance of two binary
search trees as more objects are added to them. Initially, one tree is balanced
and the other is not. First modify BinarySearchTreeInterface and
BinarySearchTree so that the add method returns the number of comparisons used.
Then write a program that uses the new version of BinarySearchTree, as follows.
Create two empty binary search trees. Associate two variables with each tree.
One variable sums the number of comparisons used in adding values to a tree,
and the other sums the heights of a tree at certain times following the
insertion of several values.

Compare the performance of two binary
search trees as more objects are added to them. Initially, one tree is balanced
and the other is not. First modify BinarySearchTreeInterface and
BinarySearchTree so that the add method returns the number of comparisons used.
Then write a program that uses the new version of BinarySearchTree, as follows.
Create two empty binary search trees. Associate two variables with each tree.
One variable sums the number of comparisons used in adding values to a tree,
and the other sums the heights of a tree at certain times following the
insertion of several values. Name these variables comparisonSum1,
comparisonSum2, heightSum1, and heightSum2. In a loop that executes 100 times,
do the following:

Add the values 1000, 2000, 3000, 4000,
5000, 6000, and 7000 to both trees. In the first tree, add them in increasing
order. In the second, add them in an order that forms a complete tree. Your
first tree will be unbalanced, while the second tree will be balanced.

Generate 10 random values between 0 and
8000. Add these values to each tree in the same order.

After each of these additions, update each
trees comparison Sum variable by the number of comparisons performed for the
insertion.

Add each trees height to its height Sum
variable.

Clear the two trees.

After the loop ends, compute the average
number of comparisons needed to insert values into each tree. (For each tree,
divide its comparison Sum by 1000. Note that 1000 is 100the number of
iterationsmultiplied by 10the number of values inserted in one iteration.)
Also compute the average height of each tree after the insertions. (Divide each
height Sum variable by 100.) Display and record your results. Run the program a
second time, but instead add 100 random values between 0 and 8000 during each
iteration of the loop. Run it a third time, but instead add 1000 random values.
Discuss your results and draw a conclusion.

## Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
\$26
The price is based on these factors:
Number of pages
Urgency
Basic features
• Free title page and bibliography
• Unlimited revisions
• Plagiarism-free guarantee
• Money-back guarantee
On-demand options
• Writer’s samples
• Part-by-part delivery
• Overnight delivery
• Copies of used sources
Paper format
• 275 words per page
• 12 pt Arial/Times New Roman
• Double line spacing
• Any citation style (APA, MLA, Chicago/Turabian, Harvard)

# Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

### Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

### Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

### Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.