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!
define A as array of size [ROWS][COLUMNS] or
define A as array of size (ROWS, COLUMNS)
define A as array of size [5][6]
define A as array of size (5, 6)
Usually IB papers will have defined it for you, or they may not ask you at all to define the size. You could define it (unknown size) as
define A as 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.

No comments:

Get back the command prompt in Windows 10

If you've updated your Windows 10 system to the Creators Update (or newer), you may have noticed that the contextual menu (shift+right c...