Question: Write three c++ functions using recursion: 1. size_t replaceTargetInteger( int target, int value, int anArray[], size_t size); Replace all occurrences of a target integer in

Write three c++ functions using recursion:

1. size_t replaceTargetInteger(int target, int value, int anArray[], size_t size);

Replace all occurrences of a target integer in an array with 'value', and return the number of replacements performed. size is the array's size and it is positive.

For example, int anArray[5] = {11, 0, 11, 9, 11}. replace(11, 10, anArray, 5) should change the array to {10, 0, 10, 9, 10} and return 3

 2. void initializeGivenElements(int anArray[], int value, size_t lowerBound, size_t upperBound);
Given index lowerBound and index upperBound, initialize elements in an array between the lowerBound and upperBound to 'value',
(including element at lowerBound and element at upperBound). The size of the array is unknown.
Requirement: using pointer arithmetic to divide the array segment in half and perform recursive calls on each half
For example, arrayInitialize(anArray, 5, 2, 8) should set the elements between index 2 to index 8 to 5 3. bool determineSquares(int anArray[], size_t size);
Determine if each number in the array (except for the first element) is the square of the number before it; size is the size of the array and it is positive. returns false if there the size is less than two.
For example, array {3, 9, 88} returns false and array {2, 4, 16, 256} returns true

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!