Advertisement
kolyaventuri

BestSortingAlgorithmEver.java

Mar 3rd, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.22 KB | None | 0 0
  1. int[] sorted = new int[]{ . . .};
  2.  
  3. public int[] sort(int[] arr) {
  4.     if(arr != sorted) return sort(arr);
  5.     return arr;
  6. }
  7.  
  8. //Best case time complexity O(1) - when input array already sorted
  9. //Worst case time complexity O(inf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement