We learned in this lesson that Merge Sorts are recursive. One of the favorite topics that College Board likes to ask is how many times a recursive method is called. With that in mind, let’s 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 count 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 100, 1000, 10k, and 100k. Run the array through the sort and print out the results of the counter. Don’t forget to reset the counter between runs! You should pay attention to the pattern that you see. Does this pattern surprise you? 10.3.7 Recursive Call
We learned in this lesson that Merge Sorts are recursive. One of the favorite topics that College Board likes to ask is how many times a recursive method is called. With that in mind, let’s 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 count 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 100, 1000, 10k, and 100k. Run the array through the sort and print out the results of the counter. Don’t forget to reset the counter between runs!
You should pay attention to the pattern that you see. Does this pattern surprise you?
10.3.7 Recursive Calls

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images









