Chiamaci oggi! Richiedi informazioni!

Orario ufficio:

Lunedì-Sabato: 9am-8pm
Sull'Articolo -
Implementazione QuickSort Ricorsivo in VbScript per ASP 3.0 di - (é stato visto 9585 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




4609

Clienti e Utenti
1057

Domini Gestiti
145

Hosting Gestiti
6511

Database
454

EMail
41

Server Virtuali
17310

Backorder .IT riusciti
20

Anni sul Mercato