This article describes the Java data structure and algorithm of the insertion algorithm to achieve numerical ordering. Share to everyone for your reference, specific as follows:
Write here to do a souvenir, the key is to understand the insertion point, at the insertion point, the initial in and out are at this insertion point, and then through in self minus the array to reorder
public static void Insertsort () {for
(int out=1; out<a.length; out++) {
int temp = a[out];
int in = out;
while (in>0&& a[in-1]>temp) {
a[in] = a[in-1];
--in;
}
A[in] = temp;
}
}
More about Java algorithms Interested readers can view the site topics: "Java data structure and algorithms tutorial", "Java Operation DOM node skills summary", "Java file and directory operation tips Summary" and "Java Cache operation Tips"
I hope this article will help you with Java programming.