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
What information on social networking sites could be used to discriminate against a potential employee
NISA [10]

the answer on plato is b

political affiliations

3 0
2 years ago
A question to determine your ability to use the reference materials effectively. Your boss has determined that you will be using
Ymorist [56]

Answer:

The answer is "implement on group 2 and group 3".

Explanation:

In the given scenario, When technology workers are using in the project teams. People like to be stable, and we can't allow wireless network transmission to maintain their security and privacy. When we considering category 1 being the only ones who have links to a higher authority, that's why Group 2 and Group 3 were needing to be implemented.

3 0
2 years ago
PHP Create a for loop that initialize with the variable $i = 10 The loop outputs $i as long as $i is greater than 1 using for lo
Tanzania [10]

Answer:

The PHP code is as follows

<?php

for ($i = 10; $i>1; $i--)

{

echo $i.' ';

}

?>

Explanation:

The code is self explanatory and doesn't require comments before it can easily understood.

The program starts with a php opening tag <?php

And it ends with the closing tag ?>

The interpretation of the question is to print integer values from 10 to 1

To do this, an iteration is needed.

The above program makes use of a for loop iteration.

Analysis;

for ( -> This shows that it is a for loop iteration

$i = 10; -> Iterating variable $i is initialized to 10 (that is; printing will start at 10)

$i>1; -> Iteration is valid while $i is greater than 1 (e.g. 2,3,4...10)

$i-- -> For every Iteration, decrease $i by 1

) -> End of Iterating condition

echo $i.' '; -> This line prints the valid values of $i. In this case, the values of $i is from 10 and stops at 2

The output is as follows

10 9 8 7 6 5 4 3 2

4 0
3 years ago
What?<br> I couldn't hear you.<br> (play along)
nexus9112 [7]

Answer:

no

Explanation:

5 0
2 years ago
What is stands for BCPL explain ?​
krek1111 [17]
Answer: Basic Combined Programming Language

Explanation: it is a procedural, imperative, and structured programming language, originally intended for writing compilers for other languages.
8 0
3 years ago
Other questions:
  • Write a Temperature class that will hold a temperature in Fahrenheit, and will provide methods to get and display the temperatur
    5·1 answer
  • Why is the len ( ) function useful when using a loop to iterate through a stack?
    6·1 answer
  • 1. Write a recursive method to determine if a character is in a list of characters in O(logN) time. Mathematically prove (as we
    13·1 answer
  • We have three containers whose sizes are 10 pints, 7 pints, and 4 pints, respectively. The 7-pint and 4-pint containers start ou
    14·2 answers
  • you have a small network in your business with just a few network devices connected along with 22 linux computers and you want t
    7·1 answer
  • Picking up sound over a great distance while making it seem to come from close up.
    11·1 answer
  • Discussion Topic
    8·1 answer
  • Is Invader Zim gonna come back?
    7·1 answer
  • (Just wondering and for fun) What can humanity do to survive after the universe dies? Assuming we have advanced tech and there a
    9·1 answer
  • Write a function, called valFrequency, that given a list of values as a parameter, counts the frequencies for each value in the
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!