1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
irga5000 [103]
2 years ago
13

Merge arrays A and B into array C using merge sort algorithm. Give final sorted numbers of C using colored numbers without showi

ng intermediate steps. For example, your answer can be [1, 3, 3, 5, 7, 7, 9, 9, 13, 25] or [1, 3, 3, 5, 7, 7, 9,9, 13, 25), or another variation. void merge(int all, int aux[], int lo, int mid, int hi) / for (int k = lo; k<= hi; k++) aux [k] a[k]; int i lo, j = mid+1; for (int k lo; k<-hi; k++) if (i > mid) ak) else if (1 > hi) a[k] else if (small (aux(j), aux[1])) a[k] else ak aux[j++); aux (i++); aux [j++); /*++ aux (i++]; 1 j++
Computers and Technology
1 answer:
sweet-ann [11.9K]2 years ago
7 0

Answer:

Explanation:

Given code:-

#include<iostream>

using namespace std; //namespace

#define RED "\033[31m" /* Red */

#define BLUE "\033[34m" /* Blue */ //color definition

#define WHITE "\033[37m" /* White */

void mergeArrays(int arr1[], int arr2[], int n1, int n2, int arr3[])

//merger sort

{

int i = 0, j = 0, k = 0;

while (i<n1 && j <n2) //iterate over both array

{

if (arr1[i] < arr2[j]) //iff array 1 element is larger

{

arr3[k] = arr1[i]; //assign to a3

k++;

i++;

}

else

{

arr3[k] = arr2[j]; //else assign array 2 to a3

j++;

k++;

}

}

//say the array turns out to br of different sizes

//let us copy the remaining elemnt to array 3

while (i < n1)

{

arr3[k] = arr1[i];

i++;

k++;

}

while (j < n2)

{

arr3[k] = arr2[j];

k++;

j++;

}

}

int main(){

int A[4] = {3,5,7,9}; //array 1 assignment

int a_size = 4;

int b_size = 6;

int B[6] = {1,3,7,9,13,25}; //array 2 assignment

int C[10]; //array 3 declearation

int a_count = 0;

int b_count = 0; //counter for both array index

mergeArrays(A,B,a_size,b_size,C); //merger function applied;

cout<<WHITE<<"A: ";

for(int i = 0; i<4; i++){

cout<<RED<<A[i]<<" ";

}

cout<<endl<<WHITE<<"B: ";

for(int i = 0; i<6; i++){

cout<<BLUE<<B[i]<<" ";

}

cout<<endl<<WHITE<<"C: ";

for(int i = 0; i<10; i++){ //iterate over C

if(C[i] == A[a_count] && a_count < a_size){

cout<<RED<<C[i]<<" ";

// if element is common in array 1 print in red

a_count++;

}

else if (C[i] == B[b_count] && b_count < b_size){

//say element was similar in array 2,  print in blue

cout<<BLUE<<C[i]<<" ";

b_count++;

}

}

cout<<endl;

}

You might be interested in
What is some effective writing techniques?
scoray [572]
Be persuasive, have form, and know what you are talking about. I would recommend using MELCON.  You can learn more about MELCON with this link.  http://melcon.weebly.com/
3 0
2 years ago
White meat and dark meat fish have slightly different nutritional characteristics. What are the nutrition characteristics of dar
Marina CMI [18]

The nutrition characteristics of eating darker meat of fish like Salmon are that it is higher in healthy Omega-3 fats. It is true, however, that as much as it has the highest Omega-3 fats, it is also likely to be highest in any potential toxins.






7 0
3 years ago
Read 2 more answers
Persons who have been given access to an installation can be counted on to be of no threat. true or false? (antiterrorism scenar
aliya0001 [1]
<span>The statement that "Persons who have been given access to an installation can be counted on to be of no threat" is false. If they are not honest enough, they could become the dangerous staff the company could ever had because he or she has access to everything, files, information, etc. That is why, in selecting a person to be trusted with such responsibility, he or she undergoes an intensive training.</span>
4 0
3 years ago
Which part of project management involves determining the required materials?
Katyanochek1 [597]
Resources I think because what u have all depends on resources
5 0
3 years ago
Read 2 more answers
If you cannot find a template on your computer that was appropriate for your task, what should you do?
DanielleElmas [232]

Answer:

The correct option for this question is File.

Explanation:

5 0
2 years ago
Other questions:
  • Is it okay to leave your car running while parked?
    15·1 answer
  • When are number list generally used ?
    10·1 answer
  • ? Question
    6·2 answers
  • How can you employ one of the most powerful interactive business tools on the Internet today?
    11·1 answer
  • If you do not want to keep a change made by the autocorrect feature, you can click the ____ button on the auto correction option
    12·1 answer
  • Which of the following is most accurate?
    10·1 answer
  • The___ allows you quickly access features such as formatting, charting, tables, and totals
    11·1 answer
  • PLEASE I NEED HELP FAST
    8·1 answer
  • Suppose you are working in a computer lab during the work you are facing window failure or other technical issues.How you will s
    12·1 answer
  • Please help me with these questions​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!