PLEASE IMPLEMENT YOUR SOLUTION RECURSIVELY IN C++. IT WOULD BE GREAT IF YOU COULD ALSO PROVIDE TEST CODE FOR IT.

The below given C++ code implements the algorithm to find the immediate successor of the entered target in the given array anArray[]. The code has been properly commented to enable the reader to understand the code better.
Explanation:
The binarySuccessor(const int anArray[], const int first, const int last, int target) takes in an array with its first and the last element's indices along with the target element that needs to be checked against the provided array to find its immediate successor.
The function first checks if the
OR the element at the array's last index is
smaller than the target. If either of the
conditions is true then the function returns -1
because if the first element's index cannot exceed the last
element's index and as the array is sorted in ascending order, the
last element cannot be smaller than the target for the
immediate successor for the target to exist.
Next, the function checks if
the
AND
the element at this index is
target.
If this case is satisfied then the function returns this index as
it is this element that the search has narrowed down to and this
element is also
target.
If these above conditions are not true then the function follows the binary search algorithm to find the immediate successor.
First, the mid of the
array is found and the element at mid is equated
with the target element. If the element at mid
target then the search space in the array shrinks
to
as the array is in ascending order and no other element
smaller than the element at mid can be greater than or equal to the
target.
If the element at mid
target then the search space in the array shrinks
to
,
as we need to find the smallest number in the array which
is greater than or equal to the target element.
We also include the mid
element in our search space here as the mid element is also greater
than the target element and can be a part of the
answer.
The function by default returns -1 when no condition is satisfied.
C++ Code:
![1 2 #include <bits/stdc++.h> using namespace std; 4 5 /* @param: const int anArray[]:the array in ascending order containing](http://img.homeworklib.com/questions/397c90a0-7fbf-11eb-85f3-f3536aa80007.png?x-oss-process=image/resize,w_560)

![48 49 50 51 52 53 54 for(int i = i printf(%d , < last ; i++) anArray[1]); ; printf(In) 56 main) is the driver function th](http://img.homeworklib.com/questions/3a80c0a0-7fbf-11eb-b400-a32f42738389.png?x-oss-process=image/resize,w_560)

Sample output:
1.

2.

3.

4.

PLEASE IMPLEMENT YOUR SOLUTION RECURSIVELY IN C++. IT WOULD BE GREAT IF YOU COULD ALSO PROVIDE...
Please help with this coding 1.You need to dynamically allocate memory to read into a number of elements. At first, you need to determine how many numbers (here, ‘n’) to be read. Next, you need to dynamically allocate memory for ‘n’ integers. As you see,‘x’ is an integer pointer which needs to dynamically allocate memory to read ‘n’integers into it fromthekeyboard. 2 Read nintegers into the allocated block using scanf. 3. Complete the printArrayfunction to display ‘n’ integers. void printArray(int...
Please implement it using recursion and it would be
great if you could provide test code as well. Thanks.
1) Implement exponentiation recursively based on the following mathematical facts , if n = even number m" = 2 1-1 1-1 n-1 2 mxm т × m T = m × (mT) If n = o a a number , You can assume n is a non-negative integer. int expo(const int m, const unsigned int n)
**IN C***
*
In this lab, you will write a program with three recursive functions you will call in your main. For the purposes of this lab, keep all functions in a single source file: main.c Here are the three functions you will write. For each function, the output example is for this array: int array[ ] = { 35, 25, 20, 15, 10 }; • Function 1: This function is named printReverse(). It takes in an array of integers...
Please answer in C++, and Please consider
ALL parts of the question, especially where it
asks the user for V. So there should be a "cin
>> V" somewhere.
The last guy did not answer it correctly so please make sure you
do! Thank You!!
Question 1 Write the following two functions. The first function accepts as input a two-dimensional array of integers. It returns two results: the sum of the elements of the array and the average The second...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array. Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...
Must be written in C++ Display results and comments Write a program that sorts a vector of names alphabetically using the selection sort and then searches the vector for a specific name using binary search. To do that, you need to write three functions: 1. void selSort (vector <string> & v): sorts the vector using selection sort 2. void display (const vector <string> & v): displays the vector contents 3. int binSearch (const vector <string> & v, string key): searches...
Need Part 1 and Part 2 please! also has to build and run, thank
you!
CSCI 40 Computer Programming Methodology I Assignment 16 Part l Write a program that declares a two dimensional array and initialize it with following integers 2 4 3 81 45 2 10 3 6 20 21 12 28-5 7 11 2 4 75041 8 5 -10 3 2 0 Then 1. Write statements that display all the numbers in the array 2. Write statements that...
in c++
Program 1 Write a program that sorts a vector of names alphabetically using the selection sort and then searches the vector for a specific name using binary search. To do that, you need to write three functions I. void selSort (vector string &v: sorts the vector using selection sort 2. void display (const vector <string & v): displays the vector contents . int binSearch (const vector <ing& v, string key): searches the vector for a key returns the...