8.2.2 Data Structures (2D Arrays) Flashcards

1
Q

What are NESTED FOR LOOPS? Give an example

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain 2D Arrays

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens when a 2D array is declared in Pseudocode?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

2D Arrays in Pseudocode

A

INTEGER table[5, 3]
DECLARE table : ARRAY[0:4, 0:2] OF INTEGER

// assigning a value to first element in 2D array
table[0, 0] = 27;

// assigning a value to last element in table
table[4, 2] = 21;

// Declaring and initialising an array
INTEGER table [5,3] = { { 24, 32, 13 },
{ 61, 26, 17 },
{ 13, 44, 99 },
{ 37, 81, 17 },
{ 09, 54, 86 } };

// Output each element of a 2D array
FOR row ← 0 TO 4 STEP 1
FOR col ← 1 TO 2 STEP 1
OUTPUT table[row,col]
NEXT row
NEXT col

// Storing input into a 2D array
FOR row ← 0 TO 4 STEP 1
FOR col ← 1 TO 2 STEP 1
INPUT table[row,col]
NEXT row
NEXT col

How well did you know this?
1
Not at all
2
3
4
5
Perfectly