Sunday 23 April 2017

2D Arrays and IB Pseudocode

This brief post shows how to create a bi-dimentional array and describe it using IB pseudocode. It isn't stated in the IB Pseudocode in Examinations or Approved notation for developing pseudocode documents, so it's my answer to it, not an official one. Don't sue me if your examiner disagrees with me! O_o
declare A as integer array of size [ROWS][COLUMNS] or
declare A as integer array of size (ROWS, COLUMNS)
declare A as integer array of size [5][6]
declare A as integer array of size (5, 6)
Obviously, integer should be replaced by the appropriate data type.
IB papers may have defined it for you, or they may not ask you at all to define the size. You could define it (unknown size) as
declare A as integer array of size [ ][ ]
...then you'd use it like
loop ROW from 0 to 5
    loop COL from 0 to 6
        output A[ROW][COL]     or    output A(ROW, COL) 
    end loop
end loop
I'd recommend going for the [ ][ ] style as it'd be more consistent with the single dimensional arrays described in the IB pseudocode documents mentioned above.

3 comments:

tachjava said...

Hi,

Useful links. Understood the concept. Thanks for sharing.

Cheers,
http://www.flowerbrackets.com/two-dimensional-array-java-program/

trustno1 said...

java 2d graphic examples
Drawing Shapes in Java

Trevor said...

Using a 2-dimensional array, display things in a manner below using a loop structure. pseudo code

8 7 6
5 4 3
2 1 0

Optimise Windows 10/11

How to optimise your Windows setup Just in case you need it. If you want a safe and conservative approach, just disable the background apps ...