Answered step by step
Verified Expert Solution
Link Copied!

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 100,1000,10k, and 100k. 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 100 elements: ** Results Hidden **
Number of recursive calls with 1000 elements: ** Results Hidden **
Number of recursive calls with 10000 elements: ** Results Hidden **
Number of recursive calls with 100000 elements: ** Results Hidden **
Challenge: See if you can write this with a loop!
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions