Question
Problem Statement Write a program that prompts the user to input two integers n and m, each should be between 1 and 20. Your program
Problem Statement
Write a program that prompts the user to input two integers n and m, each should be between 1 and 20. Your program should use a method makeArray(...) which generates a list of random numbers between 0 and 99 and stores the first n values in one array of size (n-1) and the second set of m values in another array (m-1). Both arrays will be sorted using the method insertionSort(). The contents of the two arrays will be displayed back, to the user, before and after each array is sorted using another method displayArray().
Then you will use another method mergeArrays() to merge all the elements from the previously created two arrays, into another array of size (n+m-1). The new 3rd array can be sorted inside the method as it gets merged, or using the method insertionSort(). The contents of the new array will be displayed back, to the user, before and after it is sorted using method displayArray().
The user is then prompted one more time to enter an integer key. Your program should then use another method binarySearch() which will search each of the 3 arrays for the key the user supplied. If the key is found, your program will display the index / position of where in the array the key is located and which of the arrays contain this number (1st, 2nd, or 3rd) array. Otherwise, if the user supplied a key that is not found in any of the arrays, then display a message indicating the key was not found anywhere in any of the arrays. A sample output is below,
Hint: You should be able to upgrade and re-use most of what you did in other assignments, or find sample code in the textbook for initializing, insert-sorting, displaying arrays, generating random numbers, and binary search. Explain how everything works step by step.
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