|
This article is cited in 1 scientific paper (total in 1 paper)
COMPUTING & INFORMATION TECHNOLOGY IN MATHEMATICS
Nested arrays and recursion
A. R. Esayan, N. M. Dobrovolsky Tula State Pedagogical University
Abstract:
Problem solving with data presented nested arrays, is difficult because they of the rather is unpredictаble in their structure. And here, in many cases helps recursion. Its use allows linearly according to the same scheme to implement a run on all the elements of each nesting level of any of the array, regardless of its structure and the depth of nesting. Nested array can be interpreted by a tree, whose root is the array itself, from its go arc to the array elements, etc. The leaves of this tree are scalars or strings — finite elements that are not referenced in the following arrays.
In an article for the solution of several problems of a General nature with nested arrays is offered appropriate recursive program-functions. Examples of such tasks: calculate the total number of leaves of the array; to form an array of transposed elements of the original array at all levels of nesting; determine whether a given object (scalar, string, a simple array, nested array) of a element of this array to any level of nesting; count the number of occurrences of an object in the array at all levels of nesting; collect all the leaves of the array into the vector, replacing the leaves a given array on components the vector, etc.
In all cases, recursive triad is as follows: the parameter of recursion — nest array; decomposition — transitions at all levels of nesting of arrays to their elements, and so on until the leaves; recursive base, i.e. the trivial cases in recursion — lists of arrays [1]. Offer laconic recursive programs-features of the solution are listed and some other tasks are implemented on a simple and intuitive programming language system engineering and scientific computing PTC Mathcad Prime (version 3.1) [2,3].
Note that in this system all nesting arrays are nested matrix.
Bibliography: 3 titles.
Keywords:
nested array, matrix, tree, recursion, recursive function, decomposition, PTC Mathcad.
Received: 26.03.2015
Citation:
A. R. Esayan, N. M. Dobrovolsky, “Nested arrays and recursion”, Chebyshevskii Sb., 16:3 (2015), 479–495
Linking options:
https://www.mathnet.ru/eng/cheb430 https://www.mathnet.ru/eng/cheb/v16/i3/p479
|
Statistics & downloads: |
Abstract page: | 361 | Full-text PDF : | 113 | References: | 67 |
|