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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started