Objective: Given an array of integer write a recursive solution to check if array is sorted.
Example:
int [] a = {1,2,3,4}; Output: true int [] a = {1,2,3,4,2}; Output: false
Approach: This problem can easily be solved in single iteration by just comparing adjacent elements. Fun part is to write the recursive solution. Code is self explanatory.
Code:
Output:
true