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
It’s been six months since the disk crash at CSM Tech Publishing, and the owner is breathing a little easier because you install
Semmy [17]

Answer:

Storage Spaces

Explanation:

The feature that would best accommodate his needs would be the Storage Spaces feature that has been implemented in the Windows and Windows Server systems. This feature basically takes various hard drives and combines them together, this ultimately acts as copies of each other which protect the data of each one in the unfortunate case that one of the drives tends to fail. This feature also allows you to add more drives to the existing ones with very minimal effort without restricting configuration. Which would solve the needs that are needed in this scenario.

5 0
3 years ago
Write a function named initialMatch that takes a string parameter, text, that contains only lowercase letters and whitespace. Th
Furkat [3]

Answer:

Implementing on Python for the question, the following is the code.

Explanation:

def intialMatch(l):

   word_dict={}

   for word in l.split():

       if word_dict.get(word)==None:

           word_dict[word]=[]

       for key in word_dict.keys():

           if key[0]==word[0] and (word is not key) :

               values = word_dict.get(key)

               if word not in values:

                   values.append(word)

       for key,values in word_dict.items():

           for value in values:

               if value==key:values.remove(value)

   return word_dict

t='do what you can with what you have'

print(intialMatch(t))

6 0
3 years ago
________ databases are better than relational databases at handling unstructured data such as audio clips, video clips, and pict
timofeeve [1]

Answer:

"Object-oriented" would be the correct choice.

Explanation:

  • An object-oriented database seems to be a database that subscribes to a framework containing object-depicted details. Throughout the context of the relational database management system, object-oriented is a unique product that is not as popular and most well-known as traditional web applications.
  • This indicates that internet connectivity to existing records has to implement the previously defined connections for interacting components established by that same containers.
3 0
3 years ago
Identify the commands for the following list operations.
Bumek [7]

Answer:

D

Explanation:

the answer is D because it does exactly what the problem says.

3 0
3 years ago
How to revive a computer if it functions in an unexpected manner?
julsineya [31]
This would depend on the issue the computer is having. 

In many cases though a simple reboot does the trick. 

If your computer is slow and glitches, try cleaning it for viruses and also clean the fans. If they are dusty the computer can overheat and that can cause it to slow while its working harder to cool down.

In other cases you may not be running the proper software compatible with your device, or programs may be outdated. Check online with the company that manufactured your computer to see if you need to install updates or change certain software. 

3 0
3 years ago
Other questions:
  • An analyst is reviewing the logs from the network and notices that there have been multiple attempts from the open wireless netw
    13·1 answer
  • Someone please help! Please fill this out
    10·1 answer
  • Listed items that are not in any particular order should be identified with _____.
    9·1 answer
  • What will the output be from the following program?
    5·1 answer
  • Select the correct answer.
    13·1 answer
  • Assume that name has been declared suitably for storing names (like "Misha", "Emily" and "Sofia"). Assume also that stdin is a v
    9·1 answer
  • Write a Bare Bones program that takes as input two variables X and Y. (Again, assume these values are set before your program be
    10·2 answers
  • What are horizontal and vertical page break? how and where are these inserted?​
    10·1 answer
  • According to which virtue do you need to secure information by limiting computer access to authorized personnel only?
    6·1 answer
  • Explain the<br>4 ways<br><br>ways of arranging icons.<br><br>​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!