Joe Strazzere - All Things Quality

Visit my new blog at http://strazzere.blogspot.com/


December 1, 2005 - WinTask - BubbleSort

Posted in WinTask

'
' BubbleSort - sort an array
'
' Author: Joe Strazzere

 

Dim TheArray(5)

 

TheArray(0)=Random(99999)
TheArray(1)=Random(99999)
TheArray(2)=Random(99999)
TheArray(3)=Random(99999)
TheArray(4)=Random(99999)

 

IsNotSorted = 0
IsSorted = 1
 
LastElementInArray = 4
 
SortedFlag = IsNotSorted
 

While SortedFlag = IsNotSorted
    SortedFlag = IsSorted
    Index = 0
    While Index < LastElementInArray
        If TheArray(Index) > TheArray(Index + 1) Then
            Temp = TheArray(Index + 1)
            TheArray(Index + 1) = TheArray(Index)
            TheArray(Index) = Temp
            SortedFlag = IsNotSorted
        End If
        Index = Index+1
    Wend
Wend
 
MsgBox(Str$(TheArray(0))+CRLF+Str$(TheArray(1))+CRLF+Str$(TheArray(2))+CRLF+Str$(TheArray(3))+CRLF+Str$(TheArray(4)))


<- Last Page :: Next Page ->

About Me

A gathering place for information and ideas about Quality Assurance, Testing, and other useful topics.

Problems cannot be solved by the same level of thinking that created them. - A. Einstein

Search This Site

Translate This Site

RSS Feed

Subscribe

Twitter

@jstrazzere

Categories

Life
QA
Sports
Tools
WinTask
Work in General

What I'm Reading Now