Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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 tree's comparisonSum variable by the number of comparisons performed for the insertion.

• Add each tree's height to its heightSum 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 comparisonSum by 1000. Note that 1000 is 100-the number of iterations-multiplied by 10-the number of values inserted in one iteration.) Also compute the average height of each tree after the insertions. (Divide each heightSum 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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92209333

Have any Question?


Related Questions in Computer Engineering

The data reflects student enrollment at a college in

The data reflects student enrollment at a college in Southern California. Traditional math pathwayAccelerated math pathwayRow totalsFemale12441161360Male1054541108Column totals22981702468 We want to determine if the prob ...

Small business e-commerce portals check out small business

Small Business e-Commerce Portals Check out Small Business Center and the other e-commerce portals mentioned. Then answer the questions. Note: Small Business Center and Entrabase.com are interesting sites that offer a wi ...

Question skyeducation will develop a new branch in the city

Question : SkyEducation will develop a new branch in the city for J2EE programming training. The information is given in the following table. (Ignore the crashing parameters.) Task a b c d e f g Predecessors - - - a b c ...

A federal agency responsible for enforcing laws governing

A federal agency responsible for enforcing laws governing weights and measures routinely inspect packages to determine whether the weight of the content is at least as great as that advertised on the package. A random sa ...

We use typecasting when we want to cast a value of one type

We use typecasting when we want to cast a value of one type to a value of another type. Specifically, in this program, we want to convert a value of type double to a value of type int. Recall that Java lets you assign a ...

Use the normal model n110756 for the weights of steersa

Use the Normal model ?N(1107?,56) for the weights of steers. A) What weight represents the 49th Percentile? B) What weight represents the 99th Percentile? C) What's the IQR of the weights of these steers?

Now assume that this market becomes perfectly competitive

Now, assume that this market becomes perfectly competitive. The production process for the good does not change. So, all firms have the same cost curves as the monopolist. Reference from: Q3. A monopolist in the sugar ma ...

Directionspick one topic for word and one topic

Directions Pick one topic for Word and one topic for PowerPoint to discuss. Word Watermark: What is the purpose of watermark for a document? What do you consider when you work on a watermark in Word? Newsletter: What are ...

Question you are required to sort a file containing

Question : You are required to sort a file containing integers between 0 and 999999. You cannot afford to use one million pigeon-holes, so you decide instead to use one thousand pigeon-holes numbered from 0 to 999. You b ...

Any help will be appreciatedscenarionbspyou are a

Any help will be appreciated Scenario: You are a networking and communications consultant working for HoustonComm Services, Inc, further referred to as HCS. HCS is a company providing technology consulting services to st ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As