|
|
|
Click here to copy the following block |
Dim S1(L To R) As String Dim P1(L To R) As Long Dim L1(L To R) As Long For I = L To R S1(I) = GetRandomString() P1(I) = I L1(I) = GetRandomLong() Next I
pShellSortS L, R, S1, P1 ShellSortL L, R, L1
Sub pShellSortS(L As Long, R As Long, A() As String, P() As Long) Dim GAP As Long Dim I As Long Dim J As Long Dim TMP As Long
GAP = 1 While GAP * 3 < R - L GAP = GAP * 3 + 1 Wend While GAP > 0 For I = GAP + 1 To R TMP = P(I) J = I Do While J > GAP If A(P(J - GAP)) > A(TMP) Then P(J) = P(J - GAP) J = J - GAP Else Exit Do End If Loop P(J) = TMP Next I GAP = GAP / 3 Wend End Sub
Sub ShellSortL(L As Long, R As Long, A() As Long) Dim GAP As Long Dim I As Long Dim J As Long Dim TMP As Long
GAP = 1 While GAP * 3 < R - L GAP = GAP * 3 + 1 Wend While GAP > 0 For I = GAP + 1 To R TMP = A(I) J = I Do While J > GAP If A(J - GAP) > TMP Then A(J) = A(J - GAP) J = J - GAP Else Exit Do End If Loop A(J) = TMP Next I GAP = GAP / 3 Wend End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|