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
xxTIMURxx [149]
4 years ago
12

Finish and test the following two functions append and merge in the skeleton file:

Computers and Technology
1 answer:
avanturin [10]4 years ago
4 0

Answer:

Explanation:

#include <iostream>

using namespace std;

int* append(int*,int,int*,int);

int* merge(int*,int,int*,int);

void print(int*,int);

int main()

{ int a[] = {11,33,55,77,99};

int b[] = {22,44,66,88};

print(a,5);

print(b,4);

int* c = append(a,5,b,4); // c points to the appended array=

print(c,9);

int* d = merge(a,5,b,4);

print(d,9);

}

void print(int* a, int n)

{ cout << "{" << a[0];

for (int i=1; i<n; i++)

cout << "," << a[i];

cout << "}\n";

}

int* append(int* a, int m, int* b, int n)

{

int * p= (int *)malloc(sizeof(int)*(m+n));

int i,index=0;

for(i=0;i<m;i++)

p[index++]=a[i];

for(i=0;i<n;i++)

p[index++]=b[i];

return p;

}

int* merge(int* a, int m, int* b, int n)

{

int i, j, k;

j = k = 0;

int *mergeRes = (int *)malloc(sizeof(int)*(m+n));

for (i = 0; i < m + n;) {

if (j < m && k < n) {

if (a[j] < b[k]) {

mergeRes[i] = a[j];

j++;

}

else {

mergeRes[i] = b[k];

k++;

}

i++;

}

// copying remaining elements from the b

else if (j == m) {

for (; i < m + n;) {

mergeRes[i] = b[k];

k++;

i++;

}

}

// copying remaining elements from the a

else {

for (; i < m + n;) {

mergeRes[i] = a[j];

j++;

i++;

}

}

}

return mergeRes;

}

You might be interested in
In the ______ algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing requests till the
Ahat [919]

Answer:

elevator , SCAN

Explanation:

In the elevator algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing requests till the other end of the disk. At the other end, the direction is reversed and servicing continues. SCAN

8 0
3 years ago
Which line defines a valid CSS rule?
sladkih [1.3K]

Answer:

i beleive its c  

Explanation:

sorry if its wrong thats what i think it is

5 0
3 years ago
Read 2 more answers
What is a zener diode
V125BC [204]

a form of semiconductor diode in which at a critical reverse voltage a large reverse current can flow.
8 0
3 years ago
What are three special purpose devices you might find in a data center and what do they do?
Alinara [238K]
The <span>three special purpose devices one might find in a data center and what they do are : 
</span><span>1) Load Balancer</span><span> is a device that acts as a reverse proxy and distributes network or application traffic across a number of. servers.</span><span>
2) Logical Servers are logically separate servers (e.g., a Web server, an email server, and a file server) on the same physical computer. 
</span>3) V<span>irtual Servers ran on the same physical computer </span>that shares hardware and software resources with other operating systems (OS), they are popular in Web hosting environments.
6 0
3 years ago
Consider the following declaration: (1, 2) double currentBalance[91]; In this declaration, identify the following: a. The array
Rom4ik [11]

Answer:

Following are the solution to the given choices:

Explanation:

Given:

double currentBalance[91];//defining a double array  

In point a:  

The name of the array is= currentBalance.  

In point b:  

91 double values could be saved in the array. It requires 8bytes to hold a double that if the array size is 91*8 = 728

In point c:  

Each element's data type is double.

In point d:  

The array index range of values is between 0 and 90 (every array index starts from 0 and ends in N-1, here N=91).  

In point e:  

To access first element use currentBalance[0], for middle currentBalance[91/2] , for last currentBalance[90]

3 0
3 years ago
Other questions:
  • 8.14 Consider a system in which bus cycles takes 500 ns. Transfer of bus control in either direction, from processor to I/O devi
    7·1 answer
  • Customer A with a Bronze service level package calls in a Critical System Failure at 9:00 AM. Customer B with a Silver service l
    15·1 answer
  • Which statement is most likely to be true about a computer network?
    11·2 answers
  • Which statements accurately describe the Bookmark feature in the Audio/Video control bar? Check all that apply.
    13·1 answer
  • Hosts A and B are 20 000 km away from each other. The propagation speed of the link between them is 25000 mps. The data is place
    9·1 answer
  • Universal Containers uses a custom object within the product development team. Product development, executives, and System Admin
    11·1 answer
  • We _____to separate the code in sub programs from the main code<br><br> Please help!!
    10·2 answers
  • Which two programming languages require the program to be converted into executable code using a compiler? (Choose two.)
    5·1 answer
  • Imagine that you are in the market for a digital camera. Would it be better for you to purchase a high-quality digital camera or
    7·1 answer
  • The development methodology where each part of a project is done in order after each other is called:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!