Reference no: EM131399525
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.
What is the big oh performance of this method
: By continuing in this manner, you can sort the array into descending order. If you use a minheap instead of a maxheap, you will sort the array into ascending order.
|
A tough road north for central american children
: To stimulate your thinking about the ongoing refugee crisis, I have created a section on the web page (left hand side) called UNHCR stories. The weekend before each class, I will add a link to a news article on the UNHCR website.
|
Write an algorithm that will give you a heap again
: Consider an array that represents a heap. Suppose that you replace the value at index i with a new value. It is likely that you will no longer have a heap. Write an algorithm that will give you a heap again.
|
Determining the desaster recovery
: A disaster recovery plan is a set of policies and procedures designed to mitigate the damage of a disaster. Research some best practices for Disaster recovery. Discuss your findings.
|
Compare the performance of two binary search trees
: 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.
|
Authentication methods that can be used
: What are the authentication methods that can be used? Name some methods
|
Write a program that prompts
: Paula and Danny want to plant evergreen trees along the back side of their yard. They do not want to have an excessive number of trees. Write a program that prompts the user to input the following:
|
Whether or not empirical rule would apply to remaining data
: Explain whether or not the Empirical Rule would apply to the remaining data if the outlier(s) were removed from the dataset.
|
Describe how you will link the image of the firm
: MPR events are all around us. They can be large, small, formal, or informal and can often include more than one organization. Using the company that you further developed in the Unit 3 Individual Project, plan an event that will be a good fit for ..
|