Question: Implement c++ function rearrange1(), member functions of the DArray class. The function rearranges the data in the calling object so that the even numbers are

Implement c++ function rearrange1(), member functions of the DArray class.

The function rearranges the data in the calling object so that the even numbers are stored before the odd numbers. Follow the algorithm below.

Create 2 dynamic arrays to store even and odds numbers retrieved from the calling object. Copy the data from the "even" array into the calling object. Copy the data from the "odd" array into the calling object. Delete all dynamic data and null the pointers.

Assumption: There are at most two distinct digits in all test cases.

Example of what the result should be:

Calling object has 7 elements: 1 4 1 4 4 1 1

Function runs...

Calling object has 7 elements: 4 4 4 1 1 1 1

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!