|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Out of stack problem..
hi all,
I m creating a macro that performs sorting.I m using quicksort algoritm.Its working fine for data below 5000 but as soon as data exceeds beyond it . It shows Run-time error - 28 out of stack. Is there any way to avoid too many recursion?? Please help me out... Sub RecursiveSort(ByVal llow As Long, ByVal lHigh As Long) Dim lStart As Long Dim lEnd As Long Dim vTemp As Variant Dim vPivot As Variant lStart = lHigh lEnd = llow vPivot = a_vRowElements(lEnd) 'Till the count is less or equal to the max limit Do While lEnd <= lStart If bChkFlag = True Then ' While a_vRowElements(lEnd) < vPivot While Compare(a_vRowElements(lEnd), vPivot) lEnd = lEnd + 1 Wend 'While a_vRowElements(lStart) > vPivot While Compare(vPivot, a_vRowElements(lStart)) lStart = lStart - 1 Wend Else 'While a_vRowElements(lEnd) > vPivot While Compare(vPivot, a_vRowElements(lEnd)) lEnd = lEnd + 1 Wend 'While a_vRowElements(lStart) < vPivot While Compare(a_vRowElements(lStart), vPivot) lStart = lStart - 1 Wend End If ' If lStart >= lEnd Then If lStart <> lEnd Then vTemp = a_vRowElements(lEnd) a_vRowElements(lEnd) = a_vRowElements(lStart) a_vRowElements(lStart) = vTemp End If lStart = lStart - 1 lEnd = lEnd + 1 End If Loop If llow <= lStart Then RecursiveSort llow, lStart End If If lEnd < lHigh Then RecursiveSort lEnd, lHigh End If End Sub |
|
#2
|
||||
|
||||
|
Quote:
Quicksort is a horrid sorting algorithm that requires lots of memory and time. There are better sorts available.
__________________
Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. Not FDIC insured |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Out of stack problem.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|