Cambridge AS Computer science

SORTING
= Bubble Sort =

        
DECLARE Values : ARRAY[1:10] OF INTEGER ECLARE Swap: BOOLEAN DECLARE Len: INTEGER # User inputting elements into the array FOR ind ← 1 TO 10 OUTPUT "Enter a number:" INPUT Values[ind] NEXT ind # Sorting the array Len ← 10 REPEAT Swap ← FALSE FOR x ← 1 To Len - 1 # This loop is to do one pass through the array IF Values[x] > Values[x+1] THEN Temp ← Values[x] Values[x] ← Values[x+1] Values[x+1] ← Temp Swap ← TRUE # True if any swapping happened in this pass ENDIF Len ← Len - 1 NEXT Len UNTIL Len < =1 OR Swap = FALSE

Get In Touch

123 Street, New York, USA

info@ictmadesimple.com

+012 345 67890

Newsletter

Follow Us

© www.ictmadesimple.com. All Rights Reserved.