Προς το περιεχόμενο

sorting algorithms with pascal


psychomodo

Προτεινόμενες αναρτήσεις

Δημοσ.

Paides exei kaneis se kwdika pascal kapoia kallh ekdoxh gia tous algorithmous gia insertion k quick sort?Exw grapsei k tous dio alla o kwdikas mou apo epoptikothta einai xalia kai den eimai sigouros an h ylopoihsh tous einai kallh (swsth pantos einai)..An boreite protinetai kapoio site h na mou tous sthlei kapoios sto e-mail mou [email protected]

euxaristw..

Δημοσ.

Gia vb:<p>Sub BubbleSort(vArray As Variant, L As Integer, R As Integer)

Dim I As Integer

Dim NoExchange As Boolean

Dim Temp

 

Do

NoExchange = True

R = R - 1

For I = L To R

If vArray(I) > vArray(I + 1) Then

Temp = vArray(I)

vArray(I) = vArray(I + 1)

vArray(I + 1) = Temp

NoExchange = False

End If

Next

Loop Until NoExchange

 

End Sub<p>Public Sub QuickSort(vArray As Variant, L As Integer, R As Integer)

 

Dim I As Integer

Dim J As Integer

Dim X

Dim Y

 

I = L

J = R

X = vArray((L + R) / 2)

 

While (I <= J)

 

While (vArray(I) < X And I < R)

I = I + 1

Wend

 

While (X < vArray(J) And J > L)

J = J - 1

Wend<p> If (I <= J) Then

Y = vArray(I)

vArray(I) = vArray(J)

vArray(J) = Y

I = I + 1

J = J - 1

End If

 

Wend

 

If (L < J) Then QuickSort vArray, L, J

If (I < R) Then QuickSort vArray, I, R<p>End Sub<p>Sub Selectionsort(vArray, L As Integer, R As Integer)

Dim I As Integer

Dim J As Integer

Dim best_value As Long

Dim best_j As Integer<p> For I = L To R - 1

best_value = vArray(I)

best_j = I

For J = I + 1 To R

If vArray(J) < best_value Then

best_value = vArray(J)

best_j = J

End If

Next J

vArray(best_j) = vArray(I)

vArray(I) = best_value

Next I

 

End Sub<p>

isos na mporoun na ginoun optimized analoga me tin xrisi pou tha tous kaneis ...

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...