Benvenuto sul nostro sito di servizi di hosting e registrazione domini.
Sull'Articolo -
Implementazione QuickSort Ricorsivo in VbScript per ASP 3.0 di - (é stato visto 9437 volte)

Ecco a voi l'implementazione di uno dei più veloci algoritmi di ordinamento, sapendo di fare sicuramente cosa gradita, sotto potete prelevare questa traduzione dell'Algoritmo di Ordinamento conosciuto come QuickSort in ASP/VbScript.

Sub SwapValue(ByRef ValueA, ByRef ValueB)
  Dim Tmp
  Tmp = ValueA
  ValueA = ValueB
  ValueB = Tmp
End Sub

Sub SeparaLista(ByRef MyArray(), ByVal Low, ByVal High, ByRef Pivot)
  Pivot=Low
  Low=Low+1
  Do While (High-Low>1)
    If (MyArray(Low)<=MyArray(Pivot)) And (Low<High) Then Low=Low+1
    If (MyArray(High)>=MyArray(Pivot)) And (Low<High) Then High=High-1
    If (MyArray(Low)>MyArray(High)) Then SwapValue MyArray(Low), MyArray(High)
  Loop
 If (MyArray(Pivot)>MyArray(Low)) Then
    SwapValue MyArray(Pivot), MyArray(Low)
    SwapValue Pivot, Low
 Else
    SwapValue MyArray(Pivot), MyArray(Low-1)
    Low=Low-1
    SwapValue Pivot, Low
 End If  
End Sub

Sub TreeSort(ByRef A, ByRef B, ByRef C)
  If ((A>B) And (A>C)) Then
      SwapValue A,C
   ElseIf ((B>A) And (B>C)) Then
       SwapValue B,C
    End If
  If (A>B) Then SwapValue A,B
End Sub  

Sub QuickSort(ByRef MyArray(), Low, High)
  Dim Pivot
  If (High-Low<=1) Then
    If (MyArray(Low)>MyArray(High)) Then SwapValue MyArray(Low),MyArray(High)
  ElseIf (High-Low=2) Then
    TreeSort MyArray(Low),MyArray(Low+1),MyArray(High)
  ElseIf (High-Low>2) Then
    SeparaLista MyArray, Low, High, Pivot
    QuickSort MyArray,Low,Pivot-1
    QuickSort MyArray,Pivot+1,High
  End If
End Sub





Giovanni Ceglia offre servizi Internet di sviluppo, manutenzione, messa in opera di portali per servizi, hosting, software per servizi Internet.

Tutto il materiale qui presente è © CopyRight Giovanni Ceglia dal 2003, tutti i diritti sono riservati, la copia e la redistribuzione di materiale presente su questo sito, sono vietate ove non espressamente consentito. Eventuali marchi citati appartengono ai rispettivi proprietari. Giovanni Ceglia - Servizi Informatici, Internet e Hosting, Partita IVA N. IT03972320653, Sede Legale in Via Trento N.74 84016, Pagani (Salerno) Italy, Email: webmaster(at)9euro.com, Numero di Telefono per contatti: +39 081 5153174. Iscrizione alla camera di commercio di Salerno. GloboSpace.com è il sito principale di Giovanni Ceglia per i servizi di hosting. IL Network di Giovanni Ceglia è costituito da oltre 100 siti web.