Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Merge 2 arrays in 1 array You are given a function mergeArrays which takes in two sorted arrays a and b as parameters. The first

Merge 2 arrays in 1 array
You are given a function mergeArrays which takes in two sorted arrays a and b as parameters. The first array has M elements in it. The second one also has M elements, but it's capacity is 2M. The function mergeArrays takes both the arrays as parameters along with M. Merge the first array into the second array such that the resulting array is sorted. The code to handle input and output in the format required by the test case files is already present in the system. There is no need to edit that part of the program.
Your task is to complete the body of mergeArrays with the signature provided, and to return the correct output.
Constraints
10M1,000
Sample Input:
a={3,5,6,9,12,14,18,20,25,28}
b={30,32,34,36,38,40,42,44,46,48}
Sample Output:
{3,5,6,9,12,14,18,20,25,28,30,32,34,36,38,40,42,44,46,48}
Explanation:
As stated in the question, the second array contains enough space to accommodate the 1st array. Return the merged sorted array.
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

Students also viewed these Databases questions

Question

1. Why do people tell lies on their CVs?

Answered: 1 week ago

Question

2. What is the difference between an embellishment and a lie?

Answered: 1 week ago