Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Language II Programming (28 pts) 12.(16 pts) Write a standalone function to merge two arrays arrl and arr2. Assume the two arrays are already

C++ Language

image text in transcribed

II Programming (28 pts) 12.(16 pts) Write a standalone function to merge two arrays arrl and arr2. Assume the two arrays are already sorted in non-descending order. The resulting array would contain al elements in arrl and arr2 (i.e. duplicates will be kept) in non-descending order. The result is returned as a pointer to a dynamic array created in the function. Its size is returned via the reference parameter size3 int merge (int size1/*IN/, const int arrl/IN, int size2/*IN1 const int arr2/ IN/, int& size3/*OUT/) /I Pre: arrl initializ descending order arr2 initialized with at least size2 number of elements in non-descending order /1 Post: size3 sizel+size2. The function returns a pointer to a dynamic array containing all sizel+size2 elements from arrl and arr2 in non-descending order. ed with at least siz el number of elements in non- For example, given arrl 3, 5, 6) and ar2 (2, 2, 5, 7, 9), this merge function should return 2, 2, 3,5, 5, 6, 7,9) 13. (12 pts) Add a member function found ( to a given listType class. The function will find out how many copies of ItemType value exist in the dynamic array pointed by the data member ptrItems and return the result. If the value is not in the list at all, the function will return 0. typedef int ItemType: // a general list class class listType public: int found (ItemType value // Pre: self obj and value initialized // Post: return number of times value occurs in the self obj; return 0 if value not in the list private: ItemType* ptrItems /points to the dynamic array int size; // number of items currently in the array. Items are at position 0 to size-1 Page 4 of 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Make efficient use of your practice time?

Answered: 1 week ago