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]
3 years ago
12

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

Computers and Technology
1 answer:
avanturin [10]3 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
if your instructors teaching style is very different from your learning preference your best choice is to one work on your weake
MrRissso [65]
1. Work on your weaker areas, and adjust how you learn this class material
4 0
3 years ago
A port is the point at which a peripheral device attaches to or communicates with a computer or mobile device. True False
soldier1979 [14.2K]

Answer:

True

Explanation:

Computer is a device that is electronically designed to receive input, execute task on the input and give an output or resultant value. It's electronic hardware components are driven by a central software called the operating system. Input, output, memory and storage, and processor units are categories of the hardware components of the computer.

Peripheral hardware devices are externally attached to a computer system to maximise it's functionality. They are connected through extensions like ports, PCIe extensions etc.

5 0
3 years ago
17) you need to locate an article that (1) is published by a university or proffessional association(2) is authored by clearly d
mestny [16]
Scholarly article. [email protected]
3 0
3 years ago
Is this statement true or false?
quester [9]

Answer:

NOPE

Explanation:

sometimes presentations can be for one person only. For instance if you work in a company sometimes you present for your boss only etc.

Hope this helped :)

6 0
3 years ago
Read 2 more answers
How to download music to your mp3 player off computer
skelet666 [1.2K]
For free or for money cuz for free u would do ot on ur mp3 and money i would yse apple music
3 0
2 years ago
Other questions:
  • you install teamviewer on your workstation at home so that you can ac ess it when on the road. how can you be assured that unkno
    9·1 answer
  • write a program using if condition and print fail and try again if student marks are less than 33 using if condition and print f
    5·1 answer
  • For which task is the WordArt gallery most useful?
    15·2 answers
  • Where are the worksheet tabs located
    7·1 answer
  • Grace is the editor of her school newspaper. Which feature of a word processing program would she use to make her changes visibl
    7·2 answers
  • Which option on the Format tab is used to modify particular portions of the chart?
    13·1 answer
  • Please i relly need this! ​
    11·1 answer
  • 6. kinukuha nito ang kabuuang bilang ng mga numerical na datos sa mga piniling cells
    12·1 answer
  • You have two identical print devices that are set up in a work room. Currently, the Windows print server has two printers config
    13·1 answer
  • question 1 scenario 1, question 1-5 you’ve just started a new job as a data analyst. you’re working for a midsized pharmacy chai
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!