This article describes the numerical sorting of java data structure and algorithm insertion algorithm. Share it for your reference, as follows:
Write it here as a commemoration. The key is to understand the insertion point. At the insertion point, the initial in and out are all at this insertion point, and then reorder the array by self-deducting in
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; }}For more information about Java algorithms, readers who are interested in this site can view the topics: "Java Data Structure and Algorithm Tutorial", "Summary of Java Operation DOM Node Tips", "Summary of Java File and Directory Operation Tips" and "Summary of Java Cache Operation Tips"
I hope this article will be helpful to everyone's Java programming.