This project compares the performance of 2 binary search trees as more objects are added to them. Initially, one tree is balanced and one is not. Modify the Add method so that it returns the number of comparisons used. Then create 2 empty binary search trees. Associate 2 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. In a loop that executes 100 times do the following:

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

Generate 10 random values between 0 and 9000. Add these values to each tree in the same order. After each of these additions, update each trees comparisonSum variable by the number of comparisons performed for the insertion.

Add each trees height to is heightSum variable

Clear the two trees.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.