Sometimes CLRS pseudocodes create empty matrices or tables (2D arrays):
- "let
D be a new n\times n matrix" (page 772)
- "let
m[1\subarr n, 1\subarr n] be a new table" (page 391)
Table elements are accessed using pairs of indices, e.g., m[i,j]. Matrix elements are accessed using lowercase letters with a pair of subscripts, e.g., d_{ij}.
We have a translation rule "let A[1\subarr n] be a new array" -> A = Array(1, n), and "A[i]" -> A[i].
Clarify how to translate the above examples. Explicitly add new translation rules for creation and accessors. Do we need a new Table type to encapsulate an Array of Arrays?
Moreover, sometimes arrays are also accessed with lowercase letters with a pair of subscripts, e.g., a_i. Do we need an explicit translation rule for it?
Sometimes CLRS pseudocodes create empty matrices or tables (2D arrays):
Dbe a newn\times nmatrix" (page 772)m[1\subarr n, 1\subarr n]be a new table" (page 391)Table elements are accessed using pairs of indices, e.g.,
m[i,j]. Matrix elements are accessed using lowercase letters with a pair of subscripts, e.g.,d_{ij}.We have a translation rule "let
A[1\subarr n]be a new array" ->A = Array(1, n), and "A[i]" ->A[i].Clarify how to translate the above examples. Explicitly add new translation rules for creation and accessors. Do we need a new
Tabletype to encapsulate anArrayofArrays?Moreover, sometimes arrays are also accessed with lowercase letters with a pair of subscripts, e.g.,
a_i. Do we need an explicit translation rule for it?