<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <article-id pub-id-type="doi">10.18287/1613-0073-2016-1638-820-827</article-id>
      <title-group>
        <article-title>TERNARY TREES USAGE FOR COMPUTATIONAL EXPERIMENT DATA STORAGE</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>A.N. Kovartsev</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>D.A. Popova-Kovartseva</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>E.E. Gorshkova</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Samara National Research University</institution>
          ,
          <addr-line>Samara</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2016</year>
      </pub-date>
      <fpage>820</fpage>
      <lpage>827</lpage>
      <abstract>
        <p>Repository for a great number of the suspected function runs must often be organized during the realization of numerical global optimization method or program modules testing methods. In this connection the problem of a fastaccess search of required element arises. A way to solve the problem can be found through the organization of an effective data repository, which allows for rapid implementation of the search and insertion of new elements. The binary and ternary trees storage options are considered in the paper, their comparison is made, recommendations for use of analyzed data models are reported.</p>
      </abstract>
      <kwd-group>
        <kwd>binary trees</kwd>
        <kwd>ternary trees</kwd>
        <kwd>data structures</kwd>
        <kwd>global optimization</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        Considerable volume of function "runs" must be stored during application of
numerical global optimization method (GO) [
        <xref ref-type="bibr" rid="ref1 ref2">1, 2</xref>
        ] or program modules testing methods [
        <xref ref-type="bibr" rid="ref3 ref4">3,
4</xref>
        ]. The main requirement for GO algorithms and program modules testing methods is
the speed of the algorithm. Let us assume that the computation time of function f ( x)
is sufficiently large. This situation is typical for solving optimization problems in
technical systems design process, such as gas turbine engines, aircraft, etc. Some tests
in the known GO algorithms are repeated in increments (for example, in bisection
method or its modified version [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]) and that leads to redundant computation of f ( x) .
A way to solve this problem can be found through the organization of an effective
data repository allowing for rapid implementation of the search and insertion
operations of new elements.
      </p>
    </sec>
    <sec id="sec-2">
      <title>Disadvantages of traditional binary trees usage</title>
      <p>
        Let us agree, that by the test we mean function f (x) calculation at the point
specified by optimization algorithm or function testing algorithm. Optimization methods
complexity is the total number of algorithm steps [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. However, taking into account
the high advanced computers performance, by optimization algorithms complexity it's
more accurate to mean the total number of calls to the optimizable function, since the
algorithm steps can have different complexity, and each function call takes the same
amount of time for any algorithm. On the other hand, the number of function calls is
independent of the computer processing power that allows comparing algorithms to
be implemented on computers with different performance.
      </p>
      <p>At the same time, each function call may require significant computing time
depending on the complexity of the test function.</p>
      <p>
        This article deals with the problem of data repository organizing for GO algorithm
based on the modified bisection method (BM) [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. In the BM algorithm the search
space partitioning strategy may be defined as non-uniform space division with the use
of regular structures (see [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]). However, it is necessary to compute the function at the
same points of independent variables set.
      </p>
      <p>
        In order to avoid repeated calculations, it is expedient to store the point coordinates
and function values at them in a separate data repository. Thus the data array may
have considerable size. In this case there is the problem of finding an element in the
array. For example, the average complexity of sequential search in an unordered and
in an ordered array is O(n) [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
      </p>
      <p>
        Practically, binary trees (b-trees) are generally used to increase the efficiency of the
search algorithm [
        <xref ref-type="bibr" rid="ref8 ref9">8, 9</xref>
        ]. Binary search for balanced binary trees [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] has an average
complexity proportional to O(log 2 n) and depends on the depth of a binary tree.
By the depth of a binary tree is generally understood [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] the number of nodes on the
longest path from the root of the tree to its leaves. However, usage of binary trees for
data storing at the test points of the tested or optimized function has its own aspects.
In particular, a certain procedure of data entry or additional sorting of data is required
to build an optimal balanced binary tree even for regular grids. For the irregular grids
of experiment data sorting is essential.
      </p>
      <p>Figure 2 shows the balanced binary tree built for the regular grid (see. Fig. 1) using
one of the rational methods of construction of the balanced binary tree.
In addition, computational experiment must comply with the sequence shown in
Figure 1. The calculations start from a point with coordinates (2, 2). A binary tree shown
in Figure 2 corresponds to this plan.
However, the gradual detalization of the search area is peculiar for BM, and it starts
from a large sample spacing with a gradual decrease in specific fragments in the
searching range. The range of search "densifies" nonuniformly here. In this case, it's
impractical to achieve the balance of the binary tree, and this leads to efficiency loss
of search algorithms. Figure 3 shows a binary tree corresponding to the experiment
shown in Figure 4.
As can be seen from the figure binary tree becomes not balanced for irregular grid.
One way to improve the efficiency of the search algorithm is to use more complex
data structures, such as ternary trees (t-trees).
2</p>
    </sec>
    <sec id="sec-3">
      <title>Ternary trees</title>
      <p>Two ordering relationships ("&lt;" and "&gt; =" or "&lt;=" and "&gt;") are used to build a binary
tree that allow to implement a procedure of binary division of the ordered set. Three
conditions are required for the ternary tree construction which allow to split an
ordered set into three parts. As such, will be the following conditions "&lt;", "=" and "&gt;".
Points of the experiment will be organized by the following criterion z  x  y , i.e.
by the sum of the experimental points coordinates. In general, points with coordinates
that correspond to the condition of equality, not often encountered; in this case, a
ternary tree is converted into binary. However, there is a fair amount of such points
for regular grids. Points that satisfy the condition of equality are located on the
diagonals ( x  y  const ) for 5 * 5 grid in figure 5.
The result is a t-tree, shown in Figure 6.</p>
      <p>The comparison between an average efficiency of search for b- and t-trees for
different regular grids of partitioning the search space is of some interest.</p>
      <p>
        Let n be a number of nodes of a regular grid for each coordinate, N  n2 - the total
number of grid nodes, k - the depth of a complete binary tree [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
A binary tree is "complete" if both subtrees of all nodes are "balanced", i.e. they have
approximately the same number of nodes [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
      </p>
      <p>
        The total number of nodes for a "complete" (balanced) b-tree can be calculated from
the formula [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] 2k 1 .
Suppose that the complete balanced tree is constructed for each regular grid, so that
the first few levels except the last one are completely filled with nodes. Basically, it is
impossible to build completely filled "balanced" trees for n  n grid, because the
number of elements in the grid and in complete binary tree does not match.
For any number of elements (in this case the n  n grid) the "complete" tree depth can
be calculated from the formula:
      </p>
      <p>  log2 N, if  log2 N  log2 N,
k    log2 N1, else.</p>
      <p>On the assumption of equally probable binary tree filling with the information in the
grid nodes we calculate the average complexity of the search on the "complete"
btree. For a grid with the number of elements N  n 2 , the elements of the "complete"
tree up to the depth k 1 will be completely filled. 2k elements are located on each k
level of the binary tree. It is easy to show that for equally probable distribution of
nodes of a regular grid in a binary tree the average complexity of search can be
calculated using the following formula:</p>
      <p>1
B(N )  2 (k n2  (k  1)  2k ).</p>
      <p>n
Unfortunately, "complete" balanced b-tree is generated only when the inclusion of
grid elements into a binary tree has a certain order. In general, the search process can
form linear structure with greater depth than the "complete" b-tree.</p>
      <p>
        Knuth [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] has shown that, if all possible options of elements inclusion (N!) into the
binary tree are assumed to be equally probable, then the average depth of a binary
search is N and averagely 1.386 log 2 N comparisons are required per search. Figure
7 shows graphs of average search complexity. It can be seen, that the average
complexity of the search of the "complete" binary tree is much smaller than in case of
arbitrary filling of b-tree with grid elements.
      </p>
      <p>The ternary tree depth is almost the same as the dimension of the grid, as the tree
depth cannot be less than the number of nodes on the grid diagonal because of the
equality operation. It is much more difficult to calculate the average complexity of the
search T(N) for a ternary tree. Figure 7 shows a graph of behavior T(N) of the number
of grid elements resulted from the computing experiment for quasioptimal t-trees.
As can be seen from the figure a ternary tree has disadvantages in the description of
the regular grid of the experiment in comparison with optimal binary tree. However, a
margin of free branches in the tree that can be filled with new grid nodes is very
important in the nonlinear search space partitioning method when changing the sample
spacing of the search space. In this regard, the binary tree loses much to t-tree, since
b-tree branches are located at the last level of the tree.</p>
      <p>The reservation availability for new experimental points occurs in the t-tree, which do
not increase the depth of search long enough. The latter happens because the
operation of the equality "=" implements the partition of the grid points set into equivalence
classes. All classes are comparable to operations "&lt;" and "&gt;" and form "branches" of
equivalence.</p>
      <p>Grid densifying in separate squares leads to the appearance of new branches, that
quickly find an empty place on a tree. The upper levels of binary trees tend to be
already completed by this time and further development is possible only by increasing
the depth of the tree.</p>
      <p>
        It is inappropriate to sort b-tree in order to improve its structure when the operations
of element inserting and searching for an item in the tree are made at the same time.
The fastest sorting algorithms require N log2 N operations to improve the tree
structure [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]. In this case, the efficiency of the dichotomous search on balanced b-tree
will be lost due to the sort operations.
      </p>
      <p>Thus, ternary tree can be used as the data model of experimental points placement
during software module testing.
3</p>
    </sec>
    <sec id="sec-4">
      <title>The efficiency of the search algorithm in ternary tree research</title>
      <p>
        The efficiency of the search algorithm in ternary tree depends on the properties of the
test function. We used 6 test functions with different topologies in the computational
experiments and, therefore, different computational complexity in terms of solving
the problem of GO. The functions are different: from relatively simple rational
functions, more complex ravine functions, multiextremal functions (including
discontinuous functions) to ROOT standard test functions offered on the site [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ].
Figure 8 shows the results of computational experiments of the efficiency of the
search algorithm in ternary tree research for the considered test functions. For clarity,
dependency graphs of the average search length of optimal "complete" binary tree and
evaluation of the same values for equally probable way of filling b-tree proposed by
Knuth [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] are shown below.
      </p>
      <p>As can be seen from the figure, in most cases, the efficiency of the search on the t-tree
is comparable with the average complexity of the search at the optimal binary tree.
The latter is achieved due to the large number of ternary tree free connections, located
on the upper levels. In general, the average search length of t-tree has an acceptable
value for large volumes of stored data. In comparison it should be noted that t-tree
was discussed in unsorted form, while b-tree, for the same amount of information was
optimal and balanced. The latter means the high efficiency of the search on t-trees.
If we consider the relative average search length (ratio of the average search length to
the total number of elements of the tree), then with increasing of the size of t-tree
search efficiency only increases (see Fig. 9).</p>
    </sec>
    <sec id="sec-5">
      <title>Conclusion</title>
      <p>In this article, we considered the problem of data repository organization and data
search algorithm on ternary trees, designed to serve the global optimization methods
and function tests that require processing of large volumes of information. Using of
ternary trees gives a number of advantages in comparison with traditional binary
trees, as it does not require to perform a sort operation or balance the tree in order to
improve the efficiency of the search on ternary trees, and the average complexity of
the search is comparable to the efficiency of search on the binary optimal balanced
tree.</p>
    </sec>
    <sec id="sec-6">
      <title>Acknowledgements</title>
      <p>This work was supported by the state Ministry of Education and Science of the
Russian Federation as part of the activities of the Program of competitiveness improving
of SSAU among the world's leading research and education centers for 2013-2020.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Kovartsev</surname>
            <given-names>AN</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Popova-Kovartseva</surname>
            <given-names>DA</given-names>
          </string-name>
          .
          <article-title>On efficiency of parallel algorithms for global optimization of functions of several variables</article-title>
          .
          <source>Computer Optics</source>
          ,
          <year>2011</year>
          ;
          <volume>35</volume>
          (
          <issue>2</issue>
          ):
          <fpage>256</fpage>
          -
          <lpage>261</lpage>
          . [in Russian]
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>Kovartsev</given-names>
            <surname>АN</surname>
          </string-name>
          .
          <article-title>A deterministic evolutionary algorithm for the global optimization of morse cluster</article-title>
          .
          <source>Computer Optics</source>
          ,
          <year>2014</year>
          ;
          <volume>39</volume>
          (
          <issue>2</issue>
          ):
          <fpage>234</fpage>
          -
          <lpage>240</lpage>
          . [in Russian]
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Kovartsev</surname>
            <given-names>AN</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Popova-Kovartseva</surname>
            <given-names>DA</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Abolmasov</surname>
            <given-names>PV</given-names>
          </string-name>
          .
          <article-title>Efficiency study of global parallel optimization for multivariable function</article-title>
          .
          <source>Vestnik NNGU</source>
          ,
          <year>2013</year>
          ;
          <volume>3</volume>
          (
          <issue>1</issue>
          ):
          <fpage>252</fpage>
          -
          <lpage>261</lpage>
          . [in Russian]
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>Kovartsev</given-names>
            <surname>АN</surname>
          </string-name>
          .
          <article-title>An efficient algorithm for testing the truth of assertions for real numbers expressed in relational signatures</article-title>
          .
          <source>Computer Optics</source>
          ,
          <year>2014</year>
          ;
          <volume>38</volume>
          (
          <issue>3</issue>
          ):
          <fpage>550</fpage>
          -
          <lpage>554</lpage>
          . [in Russian]
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Kovartsev</surname>
            <given-names>AN</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Popova-Kovartseva</surname>
            <given-names>DA</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gorshkova</surname>
            <given-names>EE</given-names>
          </string-name>
          .
          <article-title>Software testing based on global search of several variables functions discontinuity</article-title>
          .
          <source>Proceedings of International Conference Information Technology and Nanotechnology (ITNT-2015)</source>
          ,
          <year>2015</year>
          :
          <fpage>389</fpage>
          -
          <lpage>396</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Nemirovskij</surname>
            <given-names>AS</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yudin</surname>
            <given-names>DB</given-names>
          </string-name>
          .
          <article-title>The complexity of the problems and the effectiveness of optimization methods</article-title>
          . Moscow: Nauka,
          <year>1979</year>
          ; 384 p. [in Russian]
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Makkonel</surname>
            <given-names>J.</given-names>
          </string-name>
          <article-title>Analysis of algorithms</article-title>
          . Introductory course. Moscow: Tekhnosfera,
          <year>2002</year>
          ; 304 p. [in Russian]
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Adamenko</surname>
            <given-names>AN</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kuchukov</surname>
            <given-names>AM</given-names>
          </string-name>
          .
          <article-title>Logic programming</article-title>
          and
          <source>Visual Prolog. St. Petersburg: BHVPeterburg</source>
          ,
          <year>2003</year>
          ; 992 p. [in Russian]
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Ivanov</surname>
            <given-names>BN</given-names>
          </string-name>
          .
          <source>Discrete mathematics. Algoritms and programs</source>
          . Moscow: Laboratoriya bazovyh znanij,
          <year>2001</year>
          ; 288 p. [in Russian]
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Meyer</surname>
            <given-names>B</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Baldwin</surname>
            <given-names>K.</given-names>
          </string-name>
          <article-title>Programming methods</article-title>
          . V.
          <volume>2</volume>
          (
          <issue>3</issue>
          ). Moscow: Mir,
          <year>1982</year>
          ; 386 p.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Knuth</surname>
            <given-names>D.</given-names>
          </string-name>
          <article-title>Art of Computer Programming. Sorting and searching</article-title>
          . V. 3. Moscow: Mir,
          <year>1978</year>
          ; 848 p.
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12. Holl P.
          <article-title>Computational structure. Introduction to nonnumerical programming</article-title>
          .
          <source>Moscow: Mir</source>
          ,
          <year>1978</year>
          ; 216 p.
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <article-title>Global optimization algorithms</article-title>
          . Sourse: &lt;http:www.r-tech.narod.ru/gtest/html&gt;
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>