Recently I did some research on array templates, and it seems I got some interesting results. In Help:Template's description, we must set up arrays with a lot of templates. But now it is different. The following is a method to set up an n elements 1d array. (the italic words are some parameters to be specified.)
[[template:tmpltname]]={{tmpltname/1|par[1]=1|par[2]=2|...|par[n]=n|{{{1}}}=}}
[[template:tmpltname/1]]={{tmpltname/2|val[1]|val[2]|...|val[n]|{{{par[1]}}}=|{{{par[2]}}}=|...|{{{par[n]}}}=}}
[[template:tmpltname/2]]={{{1}}}{{{2}}}...{{{n}}}
The usage is e.g. {{tmpltname|par[x]}}, and it gives val[x]. The exact size of the three templates can be calculated with the following formula:

So its space complexity is . And How about those arrays of higher dimensions? As we all know, the nd array in any programming language is based on 1d array. So it's easy to deal with nd arrays.
See also zh:template:babel-template/programming.