Shenzhen Yikang Trading Co. Ltd., which has detected a messy message board, deleted 45 times to open the link XX. It is very familiar with the source code and tested by dk, if you enable the "admin" command, the dk system is displayed .. Search for dk in the upper-right corner .. I found that many DK systems are used t
String
_ Name; Public String Name{ Get { Return _ Name ;} Set {_ Name = Value ;}}} /// /// Regional lord /// Public Class DK: Hero, ihero{ Public DK (){_ Name = " DK " ;} Public Void Talk (){Landpyform. Form. outputresult ( " For the Lich King " );}} What are our lovely
Hill sort first selects the increment, groups the original list, and then sorts the same array using the direct insertion method, the last increment is 1, and the global sort is achieved.1 " "2 Hill Sort3 Space Complexity O (1)4 The Worst of Time complexity (POW (n,2))5 time Complexity general situation (POW (n,1.3))6 " "7 defxier_px (arr):8Size=Len (arr)9Dk=int (SIZE/2)Ten whileDk>=1: One forIinchRange (dk,size): A ifarr[i]
the existence of the k between I and J and do not go through K two possible, so you can make K=1,2,3,...,n (n is the number of cities), in the check D (IJ) and D (IK) + The value of D (KJ), in which D (IK) and D (KJ) are the shortest distances known so far between I and K and K to J, so that D (IK) +d (kj) is the shortest distance from I to J through K. So, if there is D (IJ) >d (ik) +d (kj), it means that the distance from I to go through K and J is shorter than the original I-J distance, natu
whole sequence of records to be sorted by using the span DK divided into a number of sub-sequences of the direct insertion of the order, the entire series of records "basically ordered", then the whole record is inserted in order.Stability: unstable.Complexity of: average degree of complexity O (n^1.3) (textbook requires average, optimal, worst-of-all (n^1.3)). The hill sort is an improvement of the insertion sort, except that the 1 of each compariso
58 90] 62 bytes-aligned I = 8 [10 15 18 45 46 58 62 90]Void insertsort (sqlist L) {// directly Insert the sorting int I, j; for (I = 2; I For (I = 2; I Take an integer D1 smaller than N as the first increment, and divide all records of the file into D1 groups. All records whose distance is multiples of D1 are placed in the same group. Insert and sort data in each group first. Then, repeat the group and sort data in the second incremental D2 49,38, 65,97, 13.
The incremental sequence values are
records are ordered. Now, when we need to sort 10,001st records, we find that 10,001st records need to be inserted to the first position, A total of 10000 elements need to be moved. Directly inserting the sort and move elements can only move adjacent parts, but cannot move the elements by leaps or bounds.
Hill sorting is to improve the direct insertion sorting from this point. The basic idea is: Split the entire log table to be sorted into several sub-tables, and insert and sort the sub-table
HDU 4371 generate a series of AliceBob until n or less than or equal to S (I-2)-thinking-(push the optimal step by known conditions)
Meaning: n, d1, d2 .... dm, Mr. Alice into a number S1 = 0, Bob regenerate into a number S2 = S1 + dk, then their generated number follows the condition: Si = S (I-1) + dk, or Si = S (I-1)-dk, where 1
Analysis:
Since there is no
second trip of the increment D2 is 3, the result of the previous trip is divided into 3 sub-sequences, respectively, the direct insertion sort, the result is(38 27 49 55 65 97 76).(38 27 49 55 65 97 76).The third trip's increment D3 is 1, the entire sequence is directly inserted, and the result is(49 55 65 76 97).Code (c language):1#include 2#include 3 4 #defineMaxnum 105 6 intMain ()7 {8 voidShellsort (intArray[],intNintT);//T is a sort of number of times9 intarray[maxnum],i;Tenpr
:"); * for(i=0; i){ $printf"%-3c", l.r[i].otherinfo);Panax Notoginseng } -printf"\ n"); the return ; + } A the /* + * Order table L to make a trip to the hill insert sort. This algorithm and a direct insert - * The following modifications were made compared to the sorting: $ * 1. The increment of the record position is DK instead of 1 $ * 2. R[0] Just a staging unit, not a sentry. - */ - voidShellinsert (SqList *l,intDK) the { - int
,begin,p1-1);quickSort(a,p1+1,end);}public static void main(String[] args){int[] a = {15,22,13,9,16,33,15,23,18,4,33,25,14};show(a);quickSort(a, 0, a.length-1);show(a);}}
Hill sorting Idea: Because the ordering of raw data has a certain impact on the sorting time, data is grouped by a certain step and sorted by insert sorting. The step size is continuously reduced until the step size is 1.Public class MyA {// One of the hill sorting, dk is the st
Package insert_sort;Import Java.util.Random;/* Various insertion sort*------Data Storage Range 1~s.length-1-------* Mainly include* Direct Insert Sort* Binary Insert Sort* Hill Sort* The following is a code implementation where the binary lookup function is used for binary insert sort*/public class Sort {/** Binary Search*/private static int Binaryserach (int s[], int t, int left, int. right) {int mid = 0;while (left Mid = (left + right)/2;if (T > S[mid])left = mid + 1;if (T right = Mid-1;if (t
= Len (numlist)For I in Range (0,lengthen):TryShellinsert (Numlist,step[i])Except Indexerror,e:Passdef shellinsert (NUMLIST,DK):lengthen = Len (numlist)for k in range (0,DK):For I in range (k + dk,lengthen,dk):TryIf numlist[i] temp = Numlist[i]j = I-dkWhile J >= 0:If NUMLIST[J] > Temp:Numlist[j +
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service