Question: Using the above definition of Array, implement the following Merge function. For example, if the first array is 5->7->17->13->11 and the second array is 12->10->2->4->6,

 Using the above definition of Array, implement the following Merge function.

Using the above definition of Array, implement the following Merge function. For example, if the first array is 5->7->17->13->11 and the second array is 12->10->2->4->6, the resulting array should become 5->12->7->10->17->2->13->4->11->6. If either array is longer, merge the remaining elements of the longer array at the back of the resulting array.

// formatting not required

// Merge *this* array with another array

dynamic_array & dynamic_array::Merge(const dynamic_array & Array)

#ifndef ARRAY_HPP #define ARRAY HPP #include "adt_exception. hpp" #include "iostream" template class dynamic_array final public: explicit dynamic_array(); ~dynamic_array(); explicit dynamic_array(size_t length, int start_index = 0); explicit dynamic_array(const dynamic_array& array) noexcept(false); explicit dynamic_array(const T array[], size_t size); dynamic_array& operator=(const dynamic_array& rhs); explicit dynamic_array(dynamic_array&& array) noexcept; dynamic_array& operator=(dynamic_array&& rhs) noexcept; T & operator[](int index) noexcept(false); T operator[](int index) const noexcept(false); operator bool(); int get_start_index() const; size_t get_length() const; void set_start_index(int start_index); void set_length(size_t length); private: T* storage = nullptr; size_t length_ = 0; int start_index_ = 0; }; #ifndef ARRAY_HPP #define ARRAY HPP #include "adt_exception. hpp" #include "iostream" template class dynamic_array final public: explicit dynamic_array(); ~dynamic_array(); explicit dynamic_array(size_t length, int start_index = 0); explicit dynamic_array(const dynamic_array& array) noexcept(false); explicit dynamic_array(const T array[], size_t size); dynamic_array& operator=(const dynamic_array& rhs); explicit dynamic_array(dynamic_array&& array) noexcept; dynamic_array& operator=(dynamic_array&& rhs) noexcept; T & operator[](int index) noexcept(false); T operator[](int index) const noexcept(false); operator bool(); int get_start_index() const; size_t get_length() const; void set_start_index(int start_index); void set_length(size_t length); private: T* storage = nullptr; size_t length_ = 0; int start_index_ = 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!