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]
3 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]3 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
A DSS8440 server is equipped with one power supply that is failing and requires replacement. What is the correct sequence of ste
Alisiya [41]

Answer:

ICICI oxidized sicken o'clock o'clock succinct

6 0
2 years ago
Intellectual ______ is the legal term for ownership of intangible assets such as ideas, art, music, movies, and software.
77julia77 [94]

Answer:

<u>Property</u>

Explanation:

Intellectual Property (IP) is the lawful protection of human idea/intellect by unauthorised users. These human intellects are intangible assets that have both moral and commercial value. They include ideas, art, music, movies, software e.t.c.

Common types of Intellectual property include

  • Copyrights
  • patents
  • Trade Marks
  • Trade Secrets
6 0
3 years ago
Read 2 more answers
​the complete definition of a database, including descriptions of all fields, tables, and relationships, is called a _____.
SOVA2 [1]
A rational database is a one consisting of more than one table. It includes all fields of description and its relationships. 
7 0
4 years ago
Dana is reviewing a coworker’s presentation and wants to make note of some questionable data on a chart. What steps should she t
Yuki888 [10]

Answer:

1. b.

2. c.

4. d.

Explanation:

8 0
3 years ago
Read 2 more answers
Which type of financial institution typically has membership requirements?
Anon25 [30]
Credit Union typically has membership requirements
8 0
3 years ago
Other questions:
  • Pls help me. ask yourself what would jesus do...
    14·1 answer
  • What is an online alternative to customers sending checks via mail?
    7·1 answer
  • Under what category of programs and apps do screen savers and backup programs fall?
    10·1 answer
  • In a geographic file arranged by state and then city, you would file a letter from a company that does not have an individual or
    6·1 answer
  • Which is the most likely reason film companies expanded so quickly?
    8·1 answer
  • A user reports that a workstation is continually rebooting. What can a technician do to stop the rebooting in order to troublesh
    12·1 answer
  • Another name for the office button menu is the toolbar. true or false.
    7·2 answers
  • Why would you choose a mobile device over a laptop? 1-2 sentences.
    11·1 answer
  • Which of these lists correctly counts from 1 to 5 In binary
    10·1 answer
  • What is the best method for modern businesses to authorize the use of workplace resources to its employees? a. assign them a use
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!