Question: Write a function that takes in 4 parameters: an int array, its size, the left index, and the right index; and checks if the elements
Write a function that takes in parameters: an int array, its size, the left index, and the right index; and checks if the elements between the left and right index inclusive in the int array are sorted in ascending order. If the left index is larger than the right index, swap them first. Then, if the left index is invalid eg negative, larger than the size use the leftmost valid index of the array; if the right index is invalid, use the rightmost valid index of the array. Use this function header:
bool rangedCheckforSortedint array unsigned int size, int leftIndex, int rightIndex
For example suppose there is a myIntArray created as :
rangedCheckforSortedmyIntArray will check indexes between and and return false
rangedCheckforSortedmyIntArray will check indexes between and and return true
rangedCheckforSortedmyIntArray will check indexes between and and return true
rangedCheckforSortedmyIntArray will check indexes between and and return false
You can assume the array has one or more elements and the size is always correct. Content of the int array does not change after calling this function.
Only include the aquestionh header file, and the function definition and your helper functions, if any in the source file and name it as aquestionc Do not use recursion in your answer.
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
