| 
							 
 
						 | 
						
							
								
									
										 | 
									 
									
										 | 
									 
									
										
											  Click here to copy the following block |  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  Dim S1(L To R) As Strings Dim B1(1 To nChars) As Byte Dim P1(L To R) As Long
  For I = L To R   S1(I) = GetRandomString() Next I
  StrsToBytes S1, B1, P1                           
  MSDRadixSortS L, R, B1, P1
 
 
 
  Sub MSDRadixSortS(N As Long)   Dim CH() As Integer      ReDim CH(1 To N)       ReDim STACK(1 To 1000)   StackPtr = 1   With STACK(StackPtr)     .L = 1     .R = N     .D = 0   End With   StackPtr = StackPtr + 1   RadixS CH End Sub
  Sub RadixS(CH() As Integer)   Dim L As Long   Dim R As Long   Dim D As Integer   Dim I As Long   Dim J As Long   Dim TMP As Long   Dim C As Integer   Dim NextC As Integer   Dim CNT(-1 To 127) As Long   Dim IND(-1 To 127) As Long   Dim NuCnt As Long   Dim BigCnt As Long   Dim OldSp As Long   Dim BigSp As Long      While StackPtr > 1        StackPtr = StackPtr - 1        With STACK(StackPtr)       L = .L       R = .R       D = .D     End With        If R - L > 24 Then            For I = -1 To 127         CNT(I) = 0       Next I                 For I = L To R         C = CInt(B(P(I) + D))         CH(I) = C         CNT(C) = CNT(C) + 1       Next I            IND(-1) = L                 OldSp = StackPtr                      BigCnt = 0            For I = 0 To 127         J = I - 1         NuCnt = CNT(J)         IND(I) = IND(J) + NuCnt                     If NuCnt > 1 Then           With STACK(StackPtr)             .L = IND(J)             .R = IND(I) - 1             .D = D + 1           End With           StackPtr = StackPtr + 1                   If NuCnt > BigCnt Then             BigCnt = NuCnt             BigSp = StackPtr           End If         End If       Next I            TMP = BigSp       BigSp = OldSp       OldSp = TMP                      For I = L To R                     C = CH(I)               CH(I) = -1                     Do While C >= 0                   J = IND(C)                   TMP = P(I)           P(I) = P(J)           P(J) = TMP                           NextC = CH(J)                   CH(J) = -1                   If J < R Then IND(C) = J + 1 Else Exit Do                           C = NextC         Loop                               Next I     Else       DeepInsertS B, P, L, 1 + R - L, D     End If   Wend End Sub
  Type PILE   L As Long   R As Long   D As Integer End Type
  Dim STACK() As PILE Dim StackPtr As Integer
  Sub DeepInsertS(B() As Byte, P() As Long, L As Long, N As Long, D As Integer)   Dim LP As Long   Dim RP As Long   Dim TMP As Long   Dim I As Long   Dim J As Long      For RP = L + 1 To L + N - 1     TMP = P(RP)     For LP = RP To L + 1 Step -1       I = TMP + D       J = P(LP - 1) + D       Do While B(I) = B(J)         If B(I) = 0 Or B(J) = 0 Then Exit Do         I = I + 1         J = J + 1       Loop       If CInt(B(I)) - CInt(B(J)) < 0 Then P(LP) = P(LP - 1) Else Exit For     Next LP     P(LP) = TMP   Next RP 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 ) | 
	 
 
						 | 
						
						 |