String[] B=str.split ("query|,");//query delimited or comma-separated merge ordering, recursive implementation of the public class MergeSort2 {//To merge the data in the [a,b) interval in a data array, After sorting, the data between [A,b] is in ascending order state static void MergeSort (int[] data, int a,int b) {if (a >= b) return; int mid= (a+b)/2;//split sort m
Ergesort (Data,a,mid);
MergeSort (DATA,MID+1,B);
The first two are taken or only one element executes the following merge (DATA,A,MID,B); data, [Low,mid), [Mid,high] are two pieces of data to be merged. After merging, [Low,high) the whole ordered static void merge (int[] data, int low,int Mid,int high) {int[] tmp = new int[high-low+1]; int[] A=new
INT[MID-LOW+1];
Int[] B=new Int[high-mid]; Assign to two half of the group for (int i = 0; i < a.length i++) {a[i]=data[low+i-1];} for (int i = 0; i < b.length; i++) {b[i]=data[
Mid+i];
int ai=0;//As long as it can express its position can be called a pointer, not necessarily point to the memory address, C may be pointing to the memory address int bi=0;
int ci=0; while (Ai<a.length&&bi
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/
Tree sort
public class Treesort {public static int[] Treeagain (int[] a) {//Tree sort is a waste of space, numeric 16, Sorted complete binary tree, need 31 nodes int[] AllCode = new I
Nt[2 * A.length-1]; for (int i = allcode.length-1 i >= 0; i--) {if (i-a.length + 1 >= 0) {Allcode[i] = a[i-a.length + 1];} els e {if (Allcode[i * 2 + 1] <= allcode[i * 2 + 2]) {Allcode[i] = allcode[i * 2 + 1];} else {Allcode[i] = Allcode[i *
2 + 2];
}} return AllCode; public static void Treesort (int[] a) {int allcode[] = null; while (true) {//re-assign a value before sorting AllCode = Treeagai
N (a);
if (Allcode[0]==integer.max_value) {break;}
System.out.print (Allcode[0] + "");
for (int i = 0; i < a.length i++) {if (a[i] = = Allcode[0]) {a[i] = Integer.max_value;}}
}//Tree display * * int n = 1;
* for (int i = 0; i < allcode.length i++) {* System.out.print (Allcode[i] + ""); * int x = (int) Math.pow (2, N)-2;
if (i = = x) {System.out.println (); * n++; * * * *}/** * @param args/public static void Main (string[] args) {int[] a = {26, 29, 60, 60, 11, 15, 20, 75, 100, 500, 1000, 3, 5, 6, 8, 9};
Treesort (a); }
}