Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import java.util.*;
  2.  
  3.  
  4.  
  5.  
  6. class TestClass {
  7. public static boolean checkSorted_1(int arr[],int startIndex)
  8. {
  9. if(startIndex>=arr.length-1)
  10. {
  11. return true;
  12. }
  13. if(arr[startIndex]>arr[startIndex+1])
  14. {
  15. return false;
  16. }
  17.  
  18. boolean ans= checkSorted_1(arr,startIndex+1);
  19.  
  20. return ans;
  21. }
  22. public static boolean checkSorted(int arr[])
  23. {
  24. return checkSorted_1(arr,0);
  25. }
  26. public static void main(String args[] ) throws Exception {
  27. int arr[]={5,2,3};
  28. System.out.println(checkSorted(arr));
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement