1/9
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
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
“Benefits of arrays”
Multiple instances reference single identifier, fewer identifiers needed
Easier to process/search - array can be iterated through
Makes the program easier to write / debug
“State three benefits of using an array of records to store data”
Allows for iteration, can use a loop to access records
Use of index to directly access a record in the array
Simplifies the code, reduces duplication // program easier to write
Uses and benefits of arrays
Simplify an algorithm, makes it easier to amend or add data
Are easier to understand, test and debug
It is possible to iterate through the values using a loop - make data organisation easier
Arrays of records can store multiple data types