Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class TestClass {
- public static boolean checkSorted_1(int arr[],int startIndex)
- {
- if(startIndex>=arr.length-1)
- {
- return true;
- }
- if(arr[startIndex]>arr[startIndex+1])
- {
- return false;
- }
- boolean ans= checkSorted_1(arr,startIndex+1);
- return ans;
- }
- public static boolean checkSorted(int arr[])
- {
- return checkSorted_1(arr,0);
- }
- public static void main(String args[] ) throws Exception {
- int arr[]={5,2,3};
- System.out.println(checkSorted(arr));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement