Question Solved1 Answer Using C++11. Write a function that will merge the contents of two sorted(ascending order) arrays of type double values, storingthe result in an array out- put parameter (still in ascendingorder). The function shouldn’t assume that both its input parameterarrays are the same length but can assume First array04Second arrayResult arraythat one array doesn’t contain two copies of the same value. Theresult array should also contain no duplicate values.(Hint: When one of the input arrays has been exhausted, don’tforget to copy the remaining data in the other array into theresult array.) Test your function with cases in which (1) the firstarray is exhausted first, (2) the second array is exhausted first,and (3) the two arrays are exhausted at the same time (that is,they end with the same value). Remember that the arrays input tothis function must already be sorted.

HX92Z2 The Asker · Computer Science

Using C++

11. Write a function that will merge the contents of two sorted (ascending order) arrays of type double values, storing the result in an array out- put parameter (still in ascending order). The function shouldn’t assume that both its input parameter arrays are the same length but can assume

First array

04

Second array

Result array

that one array doesn’t contain two copies of the same value. The result array should also contain no duplicate values.

(Hint: When one of the input arrays has been exhausted, don’t forget to copy the remaining data in the other array into the result array.) Test your function with cases in which (1) the first array is exhausted first, (2) the second array is exhausted first, and (3) the two arrays are exhausted at the same time (that is, they end with the same value). Remember that the arrays input to this function must already be sorted.

More
See Answer
Add Answer +20 Points
Community Answer
CATYYR The First Answerer
See all the answers with 1 Unlock
Get 4 Free Unlocks by registration

Program CodeScreenshot : Sample Output: {:[1,2,3,4,5,6,7,8,9,10]:}.. Program finished with exit code 0Press ENTER to exit console.Program Code toCopy#include <iostream>using namespace std;//Function to merge 2 sorted arraysint * merge(int *a1, int n1, int *a2, int n2){    //Initialize array to store merged array     static int ans[100];    int i1=0,i2=0,ind=0;    //Loop through both arrays     while(i1<n1&&i2<n2){        //Add minimum element to thearray         if(a1[i1]<a2[i2]){            ans[ind++] =a1[i1++];      &#16 ... See the full answer