摘要: 1 //三向切分的快速排序 2 //这种切分方法对于数组中有大量重复元素的情况有比较大的性能提升 3 4 public static void main(String[] args) 5 { 6 Scanner input = new Scanner(System.in); 7 int n = input.nextInt(); 8 int[] a = n... 阅读全文
posted @ 2019-03-29 20:15 Huayra 阅读(302) 评论(0) 推荐(0)
摘要: 1 public static void main(String[] args) 2 { 3 Scanner input = new Scanner(System.in); 4 int n = input.nextInt(); 5 int[] a = new int[n]; 6 7 a[0] = 0; //不使用第一个位置 8 for(... 阅读全文
posted @ 2019-03-25 16:52 Huayra 阅读(385) 评论(0) 推荐(0)
摘要: 1 public static void main(String[] args) 2 { 3 Scanner input = new Scanner(System.in); 4 int n = input.nextInt(); 5 int[] a = new int[n]; 6 7 ... 阅读全文
posted @ 2019-03-15 22:25 Huayra 阅读(178) 评论(0) 推荐(0)
摘要: 1 public static void main(String[] args) 2 { 3 Scanner input = new Scanner(System.in); 4 int n = input.nextInt(); 5 int[] a = new int[n]; 6 7 /... 阅读全文
posted @ 2019-03-11 21:42 Huayra 阅读(283) 评论(0) 推荐(0)
摘要: 1 public static void main(String[] args) 2 { 3 Scanner input = new Scanner(System.in); 4 int n = input.nextInt(); 5 int[] a = new int[n]; 6 7 fo... 阅读全文
posted @ 2019-03-10 21:14 Huayra 阅读(326) 评论(0) 推荐(0)
摘要: 1 //Insertion Sort 2 3 for(int i = 1; i = 0 && a[j] > key; j--) 8 a[j + 1] = a[j]; 9 a[j + 1] = key; 10 } 阅读全文
posted @ 2019-03-09 20:51 Huayra 阅读(320) 评论(0) 推荐(0)
摘要: 1 public static int rank(int[] array, int k, int front, int rear) 2 { 3 if(front > rear) 4 return -1; 5 6 int mid = front + (rear - front) / 2; 7 if(k == array[m... 阅读全文
posted @ 2019-03-09 14:42 Huayra 阅读(205) 评论(0) 推荐(0)
摘要: 1 public static int rank(int[] array, int k) 2 { 3 int front = 0, rear = array.length - 1; 4 5 while(front array[mid]) front = mid + 1; 9 else if(k < array[mid]) rear = ... 阅读全文
posted @ 2019-03-09 14:35 Huayra 阅读(132) 评论(0) 推荐(0)