Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MergeSortCounter.javaWe learned in this lesson that Merge Sorts are recursive. One of College Board s favorite things to ask is how many times a recursive
MergeSortCounter.javaWe learned in this lesson that Merge Sorts are recursive. One of College Boards favorite things to ask is how many times a recursive method is called. With that in mind, lets figure out how many times our recursive method is called for a given merge sort.
For this exercise, you are given the mergeSort and the makeRandomArray helper methods. Using the static numCalls variable, add an incrementer in the mergeSort method to count how many times it is called.
Then, in the main method, create a random array of sizes k and k Run the array through the sort and print out the results of the counter. Dont forget to reset the counter between runs!
You should pay attention to the pattern that you see. Does this pattern surprise you?
Sample Output
Number of recursive calls with elements: Results Hidden
Number of recursive calls with elements: Results Hidden
Number of recursive calls with elements: Results Hidden
Number of recursive calls with elements: Results Hidden
Challenge: See if you can write this with a loop!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started