Question: In C + + implement the following function: bool findAll ( int nums [ ] , int length, int target, int &firstIndex, int &lastIndex )
In C implement the following function:
bool findAllint nums int length, int target, int &firstIndex, int &lastIndex;
The function takes a sorted array nums sorted in ascending order and returns true if the target is found and false otherwise. Also, if the target is found, the function sets firstIndex and lastIndex to the indexes of the first and last occurrences.
If the target and nums of length contains the values then a call to findAll will return true, having set firstIndex to and lastIndex to On the other hand, if target with the same array, then the return value will still be true, but both firstIndex and lastIndex will be set to Finally if the target is with the original array, then the return value will be false, and firstIndex and lastIndex won't be assigned any values leave them unchanged
Please explain each step please thank you.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
