1/6
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
Declare a 1D array
DECLARE FirstNames : ARRAY[1:5] OF STRING
Declare a 2D array
DECLARE FullNames : ARRAY[1:5, 1:2] OF STRING
Declare row first
Array benefits
Values can be accessed through a loop-controlled variable
Easy to design, test and code
Multiple instances only need to reference one identifier
Term for minimum and maximum values an array can take
Lower bound, upper bound
Term for the variable n in the pseudocode expression
Index
Declaring membership array of type student
DECLARE Membership : ARRAY[1:3000} OF Student
Efficient bubble sort (ascending) - 2D array, 1000 students and their corresponding marks
PROCEDURE Sort()
….DECLARE Temp : INTEGER
….DECLARE NoSwaps : BOOLEAN
….DECLARE Boundary, Row, Col : INTEGER
….Boundary ← 999
….REPEAT
……..NoSwaps ← TRUE
……..FOR Row ← 1 TO Boundary
…………IF Result[Row, 2] > Result[Row + 1, 2] THEN
…………….FOR Col ← 1 TO 2
………………..Temp ← Result[Row, Col]
………………..Result[Row, Col] ← Result[Row + 1, Col]
………………..Result[Row + 1, Col] ← Temp
…………….NEXT Col
…………….NoSwaps ← FALSE
…………ENDIF
……..NEXT Row
……..Boundary ← Boundary - 1
….UNTIL NoSwaps = TRUE
ENDPROCEDURE