Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribed

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

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

e. What are notable achievements of the group?

Answered: 1 week ago