This was asked earlier. It is best if you could write one up in an exam.pfft said:Are we required to know how to write algorithms for like selection sort, insertion sort, bubble sort, etc??
i'm finding it hard to write up a selection sort
BEGIN bubbleSort
set counter = 1
set end = last index of array
WHILE end>1
counter=1
WHILE counter < last
IF thearray[current] > thearray[current+1] THEN
temp=thearray[current] //swaps the two
thearray[current]=thearray[current+1]
thearray[current+1]=temp
END IF
increment counter
ENDWHILE
decrement end
ENDWHILE
END
BEGIN MAINPROGRAM
set first to 1
set last to 100
set positionofnext to last -1
WHILE positionofnext => first //until there is no longer unsorted part
next = thearray[positionofnext]
current = positionofnext
WHILE current<last and thearray[current]>thearray[current+1]
increment current
thearray[current-1]=thearray[current]
ENDWHILE
thearray[current]=next
decrement positionofnext //reduces unsorted part by 1
ENDWHILE
END MAINPROGRAM