Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the definition of a function named isSorted that receives three arguments:

ID: 3648091 • Letter: W

Question

Write the definition of a function named isSorted that receives three arguments: an array of int, an int that indicates the number of elements of interest in the array, and a bool.

If the bool argument is true then the function returns true if and only if the array is sorted in ascending order. If the bool argument is false then the function returns true if and only if the array is sorted in descending order. In all other cases the function returns false.

You may assume that the array has at least two elements.

Explanation / Answer

IF asc == TRUE THEN IF the array if sorted in ascending order THEN RETURN TRUE ELSE RETURN FALSE END IF ELSE IF the array if sorted in descending order THEN RETURN TRUE ELSE RETURN FALSE END IF END IF this worked in mine