Introduction: This is a Data Structure Algorithm(PhP description) insert a detailed page of the sort straight binary sort in a half-fold manner, introducing PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 341542 'rolling = 'no'>
1 2 /**3 * Half-fold
Hill sort 8th Section Hill sort ExercisesFor an int array, write a hill sorting algorithm that sorts the elements of the array.Given an int array a and the size of the array n, return the sorted array. Guaranteed element is less than or equal to 2000.Test examples:[1,2,3,5,2,3],6[1,2,2,3,3,5]Java (javac 1.7)Code Auto-C
]; }} N--; System.out.println ("N=" +N); //Step:5 for(inti = 0; I ){ //swap If the previous number is greater than the last number if(A[i] > a[i+1]) {A[i]= A[i] ^ a[i+1]; A[i+1] = a[i+1] ^A[i]; A[i]= A[i] ^ a[i+1]; }} N--; returnA; }Add a For loop: Public Long[] Sort (Long[] a) { intn = a.length-1; for(intj = 0; J ){ for(inti = 0; I ){ //swap If the previous number is greater tha
precedence, each array element A[i] corresponds to a priority p[i],* Then sort based on the priority order of the array*/private static void Permutebysort (int[] data){int L (www.111cn.net) en=data.length;int Len3=len*len*len;int P[]=getrandom (1,len3,len);Bubble sortfor (int i=len-1; i>0; i--){for (int j=0; j{if (p[j]>p[j+1]){int TEMP=DATA[J];DATA[J]=DATA[J+1];Data[j+1]=temp;TEMP=P[J];P[J]=P[J+1];P[j+1]=temp;}}}}/** Element A[i] is randomly selected
The General sort algorithm is a sort of array, and it uses random access methods. However, access to the list is inefficient. In fact, you can use merge sort to sort the list efficiently. The implementation of Java then is to simply transfer all the elements into an array,
Package Com.juxuny.heap;import Java.lang.reflect.array;import Java.util.arraylist;import java.util.List;/** * Created by Juxuny on 2015/2/10. */public class Heap {private int MAX = 2 Import Com.juxuny.heap.heap;import com.juxuny.heap.node;import java.util.random;/** * Created by Juxuny on 2015/2/10. */public class Main {public static void Main (string[] args) { random random = new random (); Heap heap = new Heap (); for (int i = 0; i
Conclusion: Because the counting sort is not based on the comparison sort, the time complexity can break through O (NLGN), the count sort time complexity is O (n), the extra Space complexity is O (n);The Java implementation code is as follows:1 PackageCom.cmbc.test1;2 3 Pu
5,5 is greater than 3, do not need
to Exchange 3 5 2 6
to continue comparing 2 and 2,5 greater than 5, Exchange position 2 3 2 + 5
continue to compare 6 and 6,6 greater than 2, do not need to Exchange
5 5
3 2 5 Continue to compare 6 and 2,6 greater than 2, swap position
3 2 5 2 6 6
sink to the last, two 2 are all up (fore).
Second round
Compare 3 and 2, 3 is greater than 2, Exchange position 2 3 5 2 6
Compare 3 and 5, 5 is greater than 3, do not need to Exchange 2 3 5 2 6
compare
Basic idea:The binary insertion algorithm is an improvement to the direct insertion sorting algorithm, with the sorting principle and the direct insertion algorithm:The n order of the elements to be sorted as an ordered table and an unordered table, the beginning of the ordered table has only one element, the unordered table has n-1 elements; The sorting process
The following is a centralized sort of Java code implementation (partially referencing someone else's code): Insert Sort (insertsort)://Code Principle Public Static voidIsort (int[] a) { for(inti = 1;i ){ if(A[i] ]){
This paper implements eight commonly used sorting algorithms: Insert sort, bubble sort, select Sort, hill sort, quick sort, merge sort, heap sort and lst cardinal order.
The first is t
First, overview: This paper mainly introduces the principle of several kinds of sorting algorithms and Java implementation, including: Bubble sort, select sort, insert sort, quick sort, merge sort, etc. Second, bubble
set of unordered numbers in a row, the first number on the left is the number that has been sorted, and the other numbers are unsorted numbers. The unordered numbers are then inserted from left to right into the sorted numbers.? The direct insert sort specific algorithm is described below:? Starting with the first element, the element can be thought to have been sorted;? Takes the next element and scans the sequence of elements that have been sorted
toolbar is displayed in the upper-right corner of the code block.9. LoadfromclipboardPublicboolloadfromclipboard {get; set;}Identifies whether the Clipboard contents are copied to the edit box by default when the Syntaxhighlighter plugin edit box is opened.Ten. Tabsizepublicinttabsize {get; set;}Customizes the input width of the Tab.ClassName.public string ClassName {get; set;}Add additional CSS classes to the current element for a special style pres
analysis, the comparison number of key code and the number of record moves depend on the selection of increment factor sequence d, which can accurately estimate the comparison number of key codes and the number of movement of records in certain cases. At present, no one has given a method to select the best increment factor sequence. increment factor sequence can have a variety of ways, there are odd, but also take prime numbers, but need to note: Th
Java-based heap operation methods (heap creation, insertion, and deletion) and java operation methods
As follows:
Import java. util. arrays; // the code of the small top Heap implements public class Heap {// downward adjustment. The top Heap is mainly used to delete and crea
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.