Theory and Applications of Models
Theory and Applications of Models
Theory and Applications of Models
com
https://textbookfull.com/product/theory-and-
applications-of-models-of-computation-16th-
international-conference-tamc-2020-changsha-
china-october-18-20-2020-proceedings-jianer-
chen/
textbookfull
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://textbookfull.com/product/web-and-internet-economics-16th-
international-conference-wine-2020-beijing-china-
december-7-11-2020-proceedings-xujin-chen/
https://textbookfull.com/product/e-learning-e-education-and-
online-training-6th-eai-international-conference-
eleot-2020-changsha-china-june-20-21-2020-proceedings-part-ii-
shuai-liu/
https://textbookfull.com/product/information-systems-
security-16th-international-conference-iciss-2020-jammu-india-
december-16-20-2020-proceedings-salil-kanhere/
https://textbookfull.com/product/natural-language-processing-and-
chinese-computing-9th-ccf-international-conference-
nlpcc-2020-zhengzhou-china-october-14-18-2020-proceedings-part-
Cognitive Computing ICCC 2020 4th International
Conference Held as Part of the Services Conference
Federation SCF 2020 Honolulu HI USA September 18 20
2020 Proceedings Yujiu Yang
https://textbookfull.com/product/cognitive-computing-
iccc-2020-4th-international-conference-held-as-part-of-the-
services-conference-federation-scf-2020-honolulu-hi-usa-
september-18-20-2020-proceedings-yujiu-yang/
https://textbookfull.com/product/pattern-recognition-and-
computer-vision-third-chinese-conference-prcv-2020-nanjing-china-
october-16-18-2020-proceedings-part-iii-yuxin-peng/
Jianer Chen
Qilong Feng
Jinhui Xu (Eds.)
LNCS 12337
Founding Editors
Gerhard Goos
Karlsruhe Institute of Technology, Karlsruhe, Germany
Juris Hartmanis
Cornell University, Ithaca, NY, USA
Jinhui Xu (Eds.)
123
Editors
Jianer Chen Qilong Feng
Department of Computer Science School of Computer Science
Texas A&M University and Engineering
College Station, TX, USA Central South University
Changsha, China
Jinhui Xu
Department of Computer Science
and Engineering
State University of New York at Buffalo
Buffalo, NY, USA
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface
Program Committee
Anthony Bonato Ryerson University, Canada
Yixin Cao The Hong Kong Polytechnic University, Hong Kong,
China
Jianer Chen Texas A&M University, USA
Hu Ding University of Science and Technology of China, China
Thomas Erlebach University of Leicester, UK
Qilong Feng Central South University, China
Seok-Hee Hong The University of Sydney, Australia
Ziyun Huang Penn State Erie, The Behrend College, USA
Aaron D. Jaggard U.S. Naval Research Laboratory, USA
Steffen Lempp University of Wisconsin-Madison, USA
Jian Li Tsinghua University, China
Shi Li State University of New York at Buffalo, USA
Mia Minnes University of California, San Diego, USA
Evanthia Papadopoulou University of Lugano (USI), Switzerland
A. Pavan Iowa State University, USA
Anil Seth IIT Kanpur, India
Xiaoming Sun Institute of Computing Technology, Chinese Academy
of Sciences, China
Shin-Ichi Tanigawa The University of Tokyo, Japan
Takeshi Tokuyama Tohoku University, Japan
Haitao Wang Utah State University, USA
Lusheng Wang City University of Hong Kong, Hong Kong, China
Ge Xia Lafayette College, USA
Jinhui Xu State University of New York at Buffalo, USA
Boting Yang University of Regina, Canada
Christos Zaroliagis CTI, University of Patras, Greece
Guochuan Zhang Zhejiang University, China
Huaming Zhang University of Alabama in Huntsville, China
Martin Ziegler KAIST, China
viii Organization
Additional Reviewers
1 Introduction
The theory of numberings gives a formal approach to studying uniform computa-
tions for classes of mathematical objects. One of the first important applications
of this theory is provided by Gödel [15], who employed an effective numbering of
The work was supported by Nazarbayev University Faculty Development Competitive
Research Grants N090118FD5342. The first author was partially supported by the
grant of the President of the Russian Federation (No. MK-1214.2019.1). The third
author was partially supported by the program of fundamental scientific researches of
the SB RAS No. I.1.1, project No. 0314-2019-0002.
c Springer Nature Switzerland AG 2020
J. Chen et al. (Eds.): TAMC 2020, LNCS 12337, pp. 1–12, 2020.
https://doi.org/10.1007/978-3-030-59267-7_1
2 N. Bazhenov et al.
gν (n, x) := (ν(n))(x)
In a natural way, Definitions 1.1 and 1.2 give rise to the notion of Rogers
pr-semilattice of a punctual family S, see Sect. 2 for a formal definition. Most
of the problems on numberings in terms of Rogers semilattices, in the general
setting, can be formulated as follows:
Based on the motivation above, in our paper we show that the theory of
punctual numberings exhibits striking differences with the classical numbering
theory—The main results of the article can be summarized as follows. Let S be
an infinite punctual family.
– Below an arbitrary degree from Rpr (S), one can build an infinite descending
chain and an infinite antichain (Theorems 3.1 and 4.1). In contrast, in the
classical setting, the Rogers semilattice of, say, the family T0 := {∅}∪{{i} : i ∈
ω} has the least element.
– The semilattice Rpr (S) is dense (Theorem 6.1), i.e. given two degrees a < b,
there is always a degree c with a < c < b. On the other hand, standard
recursion-theoretic methods show that the classical Rogers semilattice of T0
has an initial segment containing precisely two degrees.
– There is a simple example of a family S1 such that the structure Rpr (S1 ) is
an infinite lattice (Proposition 5.1). Note that Selivanov [34] proved that any
infinite classical Rogers semilattice cannot be a lattice.
The proofs of these results employ some techniques developed for finitely gener-
ated punctual structures in [22] and Section 7 of [8].
It is not hard to establish the following fact (see, e.g., Proposition 3 in [12,
p. 36]). If ∈ {≤, ≤pr } and ξ is a numbering of a family S2 , then
(ν ξ & μ ξ) ⇔ (ν ⊕ μ ξ).
Let S be a punctual family of functions. By Compr (S) we denote the set of all
punctual numberings of S. Since the relation ≡pr is a congruence on the structure
Semilattices of Punctual Numberings 5
(Compr (S); ≤pr , ⊕), we use the same symbols ≤pr and ⊕ on numberings of S
and on ≡pr -equivalence classes of these numberings.
The quotient structure Rpr (S) := (Compr (S)/≡pr ; ≤pr , ⊕) is an upper semi-
lattice. We call the structure Rpr (S) the Rogers pr-semilattice of the punctual
family S.
Let T be a family of (Turing) computable functions acting from ω into ω. A
numbering ν of the family T is computable if the function gν from Definition 1.1 is
computable. Note that this definition is consistent with the notion of computable
numbering from the introduction: If we identify functions from T with their
graphs, then we will get precisely the same notions.
We say that a family T is Turing computable if it has a computable number-
ing. The definition of Rogers semilattice Rc (T ) is obtained in a similar way to
the semilattice Rpr (S), modulo the following modification: one needs to consider
all computable numberings of T and the standard reducibility ≤ between them.
If ν is a numbering, then by ην we denote the corresponding equivalence
relation on ω:
m ην n ⇔ ν(m) = ν(n).
A numbering ν is negative if the relation ην is co-c.e., i.e. ην is the complement
of a c.e. set. A numbering ν is decidable if the relation ην is (Turing) computable.
Numbering ν is Friedberg if ην is the identity relation.
Without loss of generality, one may also assume the following: if pe (x) is equal
to N , then for any t ≤ max(e, x, N ), the value pe [t](x) is undefined. The formal
details can be recovered from Section 10 of [8].
Proof. The item (a) is an easy corollary of the Mal’tsev’s result mentioned above.
We sketch the proof of the item (b).
Since the numbering ν is negative, the set
Note that checking whether ν(we ) is equal to ν(0) is a punctual procedure, since
the numbering ν is spd.
While waiting for this t to appear, we should not delay the definition of the
numbering μ, so, one by one, we put:
1. For each k ≤ pe (we ), if the object μ(k) is still undefined, then put μ(k) :=
ν(0).
2. Let m be the least index such that at this moment, μ(m) is still undefined.
Set μ(m + ) := ν(), for every ≤ we .
It is clear that the described actions ensure that the requirement Pe is for-
ever satisfied: Our choice of the witness we guarantees that we have ν(we ) =
μ(pe (we )).
The construction is arranged as follows: We start the P0 -strategy and wait
until it is satisfied. When P0 is satisfied, we immediately start the P1 -strategy.
After P1 is satisfied, we start P2 , etc.
8 N. Bazhenov et al.
The classical result of Khutoretskii [23] shows that for any computable family
T , its semilattice Rc (T ) is either one-element, or infinite. Proposition 2.1 and
Theorem 3.1 together imply that the punctual setting exhibits a similar behavior:
4 Infinite Antichain
Proof. Here we give a construction, which builds two ≤pr -incomparable punctual
numberings ν and μ of S. This construction admits a straightforward general-
ization to the case of countably many incomparable elements.
We apply Proposition 2.2 and fix a spd numbering α of the family S such
that α ≤pr β. Our numberings ν and μ will copy different pieces of α. We satisfy
the following series of requirements:
5 Lattices
Selivanov [34] obtained the following result: For any computable family T , if the
semilattice Rc (T ) is infinite, then it cannot be a lattice.
The propositions of this section show that the result of Selivanov cannot be
transferred to the punctual setting: Sometimes, an infinite Rpr (S) is a lattice,
and sometimes it is not.
Proposition 5.1. Let S be a punctual family containing the following functions:
for i ∈ ω,
gi (x) := i, for all x.
Then the structure Rpr (S) is an infinite lattice with the greatest element.
For reasons of space, the proof of Proposition 5.1 is omitted.
Proposition 5.2. There exists an infinite punctual family S such that the semi-
lattice Rpr (S) contains a minimal pair. Consequently, Rpr (S) is not a lattice.
The desired family S of Proposition 5.2 is defined via its punctual Friedberg
numbering: for k, ∈ ω, set νk, 0 := χ{2k} and νk, + 1 := χ{2k,2+1} . For
reasons of space, further proof is omitted.
10 N. Bazhenov et al.
6 Density
Recall that Theorem 3.1 proves that every infinite Rogers pr-semilattice is down-
wards dense. Proposition 5.1 gives an example of infinite Rpr (S) having the
greatest element. Thus, in general, pr-semilattices are not upwards dense.
This section contains two results. First, we provide an example of upwards
dense pr-semilattice. After that, we establish a general result (Theorem 6.1)
which proves density for an arbitrary infinite Rpr (S).
Pe : pe : μ pr ν.
The Pe -strategy. Choose the least w such that we have not talked about the
object μ(w) before. Wait for the least stage s such that the value pe [s](w) is
defined, and there is a number N ≤ s with (ν(pe (w)))(N ) = 1.
While waiting for this s, just propagate
When the stage s and the corresponding N is found, set μ(w) := χ{N +s+1} .
The construction is arranged in a straightforward way. We note that in order
to ensure the punctuality of μ, the Pe -strategy also has to implement some simple
background actions—e.g., one by one, we set μ(w + 1) := χ{0} , μ(w + 2) := χ{0} ,
etc.
Clearly, μ indexes a subfamily of S. Since every Pe is eventually satisfied, we
have μ pr ν.
Theorem 6.1. Let S be an infinite punctual family. Suppose that ν and μ are
punctual numberings of S such that ν <pr μ, i.e. ν ≤pr μ and ν ≡pr μ. Then
there is a numbering ξ ∈ Compr (S) such that ν <pr ξ <pr μ.
Acknowledgements. Part of the research contained in this paper was carried out
while the first and the last authors were visiting the Department of Mathematics of
Nazarbayev University, Nur-Sultan. The authors wish to thank Nazarbayev University
for its hospitality.
Semilattices of Punctual Numberings 11
References
1. Ambos-Spies, K., Badaev, S., Goncharov, S.: Inductive inference and computable
numberings. Theor. Comput. Sci. 412(18), 1652–1668 (2011). https://doi.org/10.
1016/j.tcs.2010.12.041
2. Badaev, S., Goncharov, S.: Computability and numberings. In: Cooper, S.B., Löwe,
B., Sorbi, A. (eds.) New Computational Paradigms, pp. 19–34. Springer, New York
(2008). https://doi.org/10.1007/978-0-387-68546-5 2
3. Badaev, S.A.: Computable enumerations of families of general recursive functions.
Algebra Log. 16(2), 83–98 (1977). https://doi.org/10.1007/BF01668593
4. Badaev, S.A.: Minimal numerations of positively computable families. Algebra Log.
33(3), 131–141 (1994). https://doi.org/10.1007/BF00750228
5. Badaev, S.A., Goncharov, S.S.: Theory of numberings: open problems. In: Cholak,
P., Lempp, S., Lerman, M., Shore, R. (eds.) Computability Theory and Its Appli-
cations, Contemporary Mathematics, vol. 257, pp. 23–38. American Mathematical
Society, Providence (2000). https://doi.org/10.1090/conm/257/04025
6. Badaev, S.A., Lempp, S.: A decomposition of the Rogers semilattice of a family
of d.c.e. sets. J. Symb. Logic 74(2), 618–640 (2009). https://doi.org/10.2178/jsl/
1243948330
7. Bazhenov, N., Mustafa, M., Yamaleev, M.: Elementary theories and hereditary
undecidability for semilattices of numberings. Arch. Math. Log. 58(3–4), 485–500
(2019). https://doi.org/10.1007/s00153-018-0647-y
8. Bazhenov, N., Downey, R., Kalimullin, I., Melnikov, A.: Foundations of online
structure theory. Bull. Symb. Log. 25(2), 141–181 (2019). https://doi.org/10.1017/
bsl.2019.20
9. Case, J., Jain, S., Stephan, F.: Effectivity questions for Kleene’s recursion theorem.
Theor. Comput. Sci. 733, 55–70 (2018). https://doi.org/10.1016/j.tcs.2018.04.036
10. Ershov, Y.L.: Enumeration of families of general recursive functions. Sib. Math. J.
8(5), 771–778 (1967). https://doi.org/10.1007/BF01040653
11. Ershov, Y.L.: On computable enumerations. Algebra Log. 7(5), 330–346 (1968).
https://doi.org/10.1007/BF02219286
12. Ershov, Y.L.: Theory of Numberings. Nauka, Moscow (1977). (in Russian)
13. Ershov, Y.L.: Theory of numberings. In: Griffor, E.R. (ed.) Handbook of Com-
putability Theory. Studies in Logic and the Foundations of Mathematics, vol. 140,
pp. 473–503. North-Holland, Amsterdam (1999). https://doi.org/10.1016/S0049-
237X(99)80030-5
14. Friedberg, R.M.: Three theorems on recursive enumeration. I. Decomposition. II.
Maximal set. III. Enumeration without duplication. J. Symb. Log. 23(3), 309–316
(1958). https://doi.org/10.2307/2964290
15. Gödel, K.: Über formal unentscheidbare Sätze der Principia Mathematica und
verwandter Systeme I. Monatshefte für Mathematik und Physik 38(1), 173–198
(1931). https://doi.org/10.1007/BF01700692
16. Goncharov, S.S.: Computable single-valued numerations. Algebra Log. 19(5), 325–
356 (1980). https://doi.org/10.1007/BF01669607
17. Goncharov, S.S.: Positive numerations of families with one-valued numerations.
Algebra Log. 22(5), 345–350 (1983). https://doi.org/10.1007/BF01982111
18. Goncharov, S.S., Lempp, S., Solomon, D.R.: Friedberg numberings of families of
n-computably enumerable sets. Algebra Log. 41(2), 81–86 (2002). https://doi.org/
10.1023/A:1015352513117
12 N. Bazhenov et al.
19. Goncharov, S.S., Sorbi, A.: Generalized computable numerations and nontrivial
Rogers semilattices. Algebra Log. 36(6), 359–369 (1997). https://doi.org/10.1007/
BF02671553
20. Herbert, I., Jain, S., Lempp, S., Mustafa, M., Stephan, F.: Reductions between
types of numberings. Ann. Pure Appl. Logic 170(12), 102716 (2019). https://doi.
org/10.1016/j.apal.2019.102716
21. Jain, S., Stephan, F.: Numberings optimal for learning. J. Comput. Syst. Sci. 76(3–
4), 233–250 (2010). https://doi.org/10.1016/j.jcss.2009.08.001
22. Kalimullin, I., Melnikov, A., Ng, K.M.: Algebraic structures computable without
delay. Theor. Comput. Sci. 674, 73–98 (2017). https://doi.org/10.1016/j.tcs.2017.
01.029
23. Khutoretskii, A.B.: On the cardinality of the upper semilattice of computable
enumerations. Algebra Log. 10(5), 348–352 (1971). https://doi.org/10.1007/
BF02219842
24. Kleene, S.C.: Introduction to Metamathematics. Van Nostrand, New York (1952)
25. Kolmogorov, A.N., Uspenskii, V.A.: On the definition of an algorithm. Uspehi Mat.
Nauk. 13(4), 3–28 (1958). (in Russian)
26. Lachlan, A.H.: Standard classes of recursively enumerable sets. Z. Math.
Logik Grundlagen Math. 10(2–3), 23–42 (1964). https://doi.org/10.1002/malq.
19640100203
27. Lachlan, A.H.: On recursive enumeration without repetition. Z. Math.
Logik Grundlagen Math. 11(3), 209–220 (1965). https://doi.org/10.1002/malq.
19650110305
28. Mal’cev, A.I.: Positive and negative numerations. Sov. Math. Dokl. 6, 75–77 (1965)
29. Metakides, G., Nerode, A.: The introduction of nonrecursive methods into mathe-
matics. In: The L. E. J. Brouwer Centenary Symposium (Noordwijkerhout, 1981).
Studies in Logic and the Foundations of Mathematics, vol. 110, pp. 319–335. North-
Holland, Amsterdam (1982). https://doi.org/10.1016/S0049-237X(09)70135-1
30. Ospichev, S.S.: Friedberg numberings in the Ershov hierarchy. Algebra Log. 54(4),
283–295 (2015). https://doi.org/10.1007/s10469-015-9349-2
31. Podzorov, S.Y.: Arithmetical D-degrees. Sib. Math. J. 49(6), 1109–1123 (2008).
https://doi.org/10.1007/s11202-008-0107-8
32. Pour-El, M.B.: Gödel numberings versus Friedberg numberings. Proc. Am. Math.
Soc. 15(2), 252–256 (1964). https://doi.org/10.2307/2034045
33. Rogers, H.: Gödel numberings of partial recursive functions. J. Symb. Log. 23(3),
331–341 (1958). https://doi.org/10.2307/2964292
34. Selivanov, V.L.: Two theorems on computable numberings. Algebra Log. 15(4),
297–306 (1976). https://doi.org/10.1007/BF01875946
35. Uspenskii, V.A.: Systems of denumerable sets and their enumeration. Dokl. Akad.
Nauk SSSR 105, 1155–1158 (1958). (in Russian)
Partial Sums on the Ultra-Wide
Word RAM
1 Introduction
Let A[1, . . . , n] be an array of integers of length n. The partial sums problem is
to maintain a data structure for A under the following operations:
i
– sum(i): return k=1 A[k].
– update(i, Δ): set A[i] ← A[i] + Δ.
The partial sums problem is a classic and well-studied data structure prob-
lem [1–4,9,12,14,16–19,21–24,31,32,38]. Partial sums is a natural range query
problem with applications in areas such as list indexing and dynamic rank-
ing [12], dynamic arrays [3,32], and arithmetic coding [14,34]. From a lower
bound perspective, the problem has been central in the development of new
techniques for proving lower bounds [29]. In classic models of computation the
complexity of the partial sums problem is well-understood with tight logarithmic
upper and lower bounds on the operations [31]. Hence, a natural question is if
c Springer Nature Switzerland AG 2020
J. Chen et al. (Eds.): TAMC 2020, LNCS 12337, pp. 13–24, 2020.
https://doi.org/10.1007/978-3-030-59267-7_2
14 P. Bille et al.
We revisit the partial sums problem on the UWRAM and present a simple new
algorithm that significantly improves the space overhead of the previous solu-
tions. Let A be an array of n w-bit integers. An in-place data structure for the
partial sums problem is a data structure that modifies the input array A, e.g.,
by replacing some of the entries in A, to efficiently support operations. In addi-
tion to the modified array the data structure is only allowed to store O(1) of
ultrawords. This definition extends the standard in-place/implicit data struc-
ture concept [10,15,30,35,37] to the UWRAM, by allowing a constant number
of ultrawords to be stored instead of (standard) words. Clearly, without this
modification computation on ultrawords is impossible. As in Farzan et al. [13]
we distinguish between the restricted UWRAM that supports a minimal set of
instructions on ultrawords consisting of addition, subtraction, shifts, and bitwise
boolean operations and the multiplication UWRAM that extends the instruction
Partial Sums on the Ultra-Wide Word RAM 15
Compared to the previous result, Theorem 1 matches the O(log log n) time bound
of Farzan et al. [13] (with parameter τ = Θ(log log n) while improving the space
overhead from O(nw log n) to a constant number of ultrawords. This is important
in practical applications since modern vector processors have a very limited
number of ultrawords available.
Technically, our solution is based on a simple and elegant in-place word RAM
data structure, called the Fenwick tree (see Sect. 3 for a detailed description).
The Fenwick tree support operations in O(log n) by sequentially traversing an
implicit tree structure. We show how to efficiently compute the access pattern on
the tree structure in parallel using prefix sum computations on ultrawords. Then,
given the locations to access we use scattered memory operations to access them
all in parallel. In total, this leads to the exponential improvement of Fenwick
trees. The main bottleneck in our algorithm is the prefix sum computation.
Interestingly, if we allow multiplication we can compute prefix sums in constant
time leading to the following Corollary for the multiplication UWRAM:
Multiplication (or prefix sum computation) is not an AC0 operation (it cannot
be implemented by a constant depth, polynomial size circuit) and therefore likely
not practical to implement on ultraword. However, Corollary 1 shows that we
can achieve significant improvements on the UWRAM with special operations.
Since UWRAM capture modern processors, we believe it is worth investigating
further, and that our work is a first step in this direction.
1.2 Outline
w
Xw − 1 X2 X1 X0
w2
Fig. 1. The layout of an ultraword of w2 divided into w words each of w bits. The
leftmost bit of each word is reserved to be a test bit.
as C. We assume that we can store a pointer into the input in a single word and
hence w ≥ log n, where n is the size of the input. The time complexity of a word
RAM algorithm is the number of instructions and the space complexity is the
number of words used by the algorithm.
The ultra-wide word RAM (UWRAM) model of computation [13] extends the
word RAM model with special ultrawords of w2 bits. We distinguish between the
restricted UWRAM that supports a minimal set of instructions on ultrawords
consisting of addition, subtraction, shifts, and bitwise boolean operations and
the multiplication UWRAM that additionally supports multiplication. The time
complexity is the number of instruction (on standard words or ultrawords) and
the space complexity is the number of (standard) words used by the algorithm.
The restricted UWRAM captures modern vector processor architectures [11,28,
33,36]. For instance, the Intel AVX-512 vector extension [33] support similar
operations on 512-bit wide words (i.e., a factor of 8 compared to 642 = 4096).
clear any test bits (we use exponentiation to denote bit repetition, i.e., 03 1 =
0001). We can also compare X and Y componentwise by |’ing in the test bits of
X, subtracting Y , and masking out the test bits by &’ing with (10w−1 )w . The jth
test bit of the result contains a 1 iff Xj ≥ Y j. Given X and another ultraword
T containing only test bits, we can extract the words in X according to the test
bits, i.e., the ultraword E such that Ej = Xj if the jth test bit of T is 1 and
Ej = 0 otherwise. To do so we copy the test bits by a subtracting (0w−1 1)w
from T and &’ing the result with X. All of the above mentioned operation take
constant time on a restricted UWRAM. Given an ultraword X of length , the
prefix sum of X is the ultraword P of length , such that P j = k≤j Xk.
We assume here that the integers computed in the prefix sum never exceed the
maximum size available in a word such that P j is always well-defined. We need
the following result.
The UWRAM supports standard memory access operation to read or write a sin-
gle word or a sequence of w contiguous words. More interestingly, the UWRAM
also supports scattered access operations that access w memory locations (not
18 P. Bille et al.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
A 1 2 1 1 0 2 3 1 0 1 3 4 1 1 1 2
F 1 3 1 5 0 2 3 11 0 1 3 8 1 2 1 24
Fig. 2. A array A and the Fenwick tree F . The lines above F indicate the partial
sum of A stored at the rightmost endpoint of the line. For instance, the F [12] =
A[9] + A[10] + A[11] + A[12] = 0 + 1 + 3 + 4 = 8.
3 Fenwick Trees
Let A be an array of n w-bit integers and assume for simplicity that n is a power
of two. The Fenwick tree [14,34] is an in-place data structure that replaces the
array A as follows. If n = 1, then leave A unchanged. Otherwise, replace all
values at even entries A[2i] by the sum A[2i − 1] + A[2i]. Then, recurse on the
subarray A[2, 4, . . . , n]. The resulting array F stores a subset of the partial sums
of A organized in a tree layout (see Fig. 1).
To answer sum(i) query, we compute a sequence of indices in F and add
the values in F at these indices together. Let rmb(x) denote the position of
the rightmost bit in an integer sx. Define the sum sequence is1 , . . . , isr given by
is1 = i and isj = isj−1 − 2rmb(ij−1 ) , for j = 2, . . . , r. The final element isr is
0. We compute and return F [is1 ] + F [is2 ] + · · · + F [isr−1 ]. For instance, for i =
13 = (1101)2 the sum sequence is 13, 12, 8, 0 = (1101)2 , (1100)2 , (1000)2 , (0000)2 .
Hence, sum(13) = F [13] + F [12] + F [8] = 1 + 8 + 11 = 20 = A[1] + · · · + A[13]. We
access at most O(log n) entries in F and hence the total time for sum is O(log n).
Note that we can always recover the original array A using the sum operation,
since A[i] = sum(i) − sum(i − 1).
To compute update(i, Δ), we compute a sequence of indices in F and add Δ
to the values in F at each of these indices. Define the update sequence iu1 , . . . , iut
u u u rmb(iu
given by i1 = i and ij = ij−1 + 2 j−1 )
, for j = 2, . . . , t. The final element iut
is 2n. We set F [i1 ] = F [i1 ] + Δ, . . . , F [it ] = F [iut−1 ] + Δ. For instance, for i = 13
u u u
the update sequence is 13, 14, 16, 32. Hence, update(13, 5) adds 5 to F [13], F [14],
and F [16]. Similar to the sum operation, the total running time for update is
O(log n).
Another random document with
no related content on Scribd:
Rohkiammaksi ruveta,
Likemmäksi liittäytä.
184—193.
Mari aina estelepi,
Sanopi sanalla tällä:
"Enkä huoli ensinkänä
Tulla kanssasi tutuksi,
Kun et laita laaullensa,
Anna kihlat kukkorosta,
Kultasormukset kuleta,
Kääri ketjut kaulahani,
Siitä tulisin tutuksi,
Likemmäksi liittähyisin."
194—206.
Riitta varsin valvovainen
Yrkön kanssa kaunihisti,
Kuultuansa kuihkutuksen,
Alko äystätä isosti.
Haukku Riitta Haapalaista,
Sanoen sanalla tällä:
"Sinä olet sika Siikajoelta,
Kehno Kestilän kylästä,
Mont' on mennyt mennävuonna,
Wiety viimmessä kesänä,
Parempata paiskattuna,
Saatettu sotaväkehen,
Etelähän ennätetty."
207—211.
Alko ajoa pihalle,
Takaperin tanhualle,
Wielä kiitti vierestänsä
Totiseksi toista miestä,
Hyvin Yrkköä ylisti.
212—228.
Samu nousi näppärästi,
Saapi lakkinsa samassa,
Kintahat ja kenkänsäki.
Lähti ulos juoksemahan,
Waan ei osannut ovehen,
Lankiapi lattialle.
Pelko paino pitkäksensä,
Pää se paukahti kivehen,
Sormet poikki portahasen,
Lakki lenti lietehesen,
Toinen kinnas kiukahalle,
Toinen sattu salvamehen,
Kengät keskelle lakia.
229—238.
Mari nousi nopiasti,
Ite pistäysi pihalle,
Otti kiini olkapäästä,
Pani kaulahan kätensä,
Lausu aivan lempehesti:
"Elä kulta kumminkana
Pane mieltäsi pahaksi
Noista töistä tuhmimmista,
Mielettömistä menoista;
Tule vielä toinen kerta!"
239—243.
Waan ei tohtinut takasin
Poika siirtyä sisälle,
Meni siitä matkohinsa,
Itku silmiä sitopi,
Weet poskille putosi.
244—256.
Mari se sisälle saapi,
Pani maata paikallensa,
Siallensa siirtäyty.
Sitte nurku nukkumatta
Riitta rukan rintavuutta,
Suupalton pauhinata:
"Kun et vaivanen varonut,
Ajot pois pojan parahan,
Minun heitit Hekkalahan,
Yrjänän ite piätit;
Minun aikani asunto,
Päivät pitkäksi tulevat,
Itkun tuottapi ikävä."
257—271.
Kesän oli kekkiänä;
Tuli sitte talven tullen,
Lähti Launolan kylältä,
Astu Antti Anttoselta,
Taitava talon isäntä.
Waunut vyöryvät kujalla,
Kiesit kiersi kartanolla,
Helisi hevosen kello,
Kovin kuulu kulkusetki,
Sulhanen oli ohjilla,
Mies on kaunis kahtannolta,
Pulskia punamerinen,
Waattchet komin koriat',
Napit kullan kiiltämäisct,
Hopiasta hohtavaisct.
272—276.
Mari luulepi lujasti,
Ett' on vieras Wiipurisla,
Saanut Saksan kaupungista,
Eli tullut Lukhulmista,
Nuohtin poika rohkiampi.
277—280.
Anna astupi tupahan,
Eellä ennätti sanoa:
"Ota oikia osasi,
Taitava talon isäntä!"
281—286.
Mari vielä muistelepi:
"Mun on haiku Haapalaista,
Jonk' on sormus sormessani,
Jonka kanssa kaiken talven
Aina valvoin valpahasti
Öillä yksillä olilla."
287—302.
Anna haukku Haapalaista,
Kieli kerkiä panepi:
"Totteletko toljaketta,
Höyhenkengän höynäystä!
Elä huoli huitarista,
Kovin konnankoukkusesta,
Jok' on ruma ruumihilta,
Partaki pahannäkönen,
Eik' ole mieltä muille asti,
Eikä ihtessä piteä.
Laaustaan on aivan laiska,
Syöpi ruoan runsahimman,
Juopi viinan kun vetenä
Ihmisiltä ilkiästi,
Aina pirtissä asupi,
Pötköttäpi pöyän päässä."
303—314.
Toista kiitti kielevästi:
"Ollut nuorena nopia,
Wiel' on virkku vanhanaki,
Kaunis kaikissa tiloissa,
Talon töihin taitavampi:
Kaikki kyllä kaunihisti
Laittelepi laaullensa,
Aina akkainki asiat.
Nametass' on naisten luona,
Leivät leipopi leviät,
Pa'at kaikki kahtelepi,
Kaikki kulkepi koatki.
315—348.
Täll' on sini silmäripset,
Tällä kulta kulmakarvat,
Tällä vaattehet verasta,
Jotka näyttävät näkyvän.
319—322.
Täll'on kihlat kirkkahimmat,
Kultasormukset soriat,
Jotka ennen aikonansa
Osti Oulun kaupungista."
323—328.
Anna kukkaron avasi,
Otti lantit lakkarista,
Jotka työnti tyttärelle.
Hyvin helisi hopiat,
Kultasormukset kulisi,
Kahlisivat kahmaloissa.
329—331.
Kohta annettiin asia,
Saatettiin sana kylälle,
Julki kaiken kirkkokunnan.
332—355.
Sinä päivänä samana
Tuli sanoma Samulle,
Ett' on Mari morsianna.
Säikähti Sameli riepu,
Weri ohtahan osasi,
Niinkun pilvi päivän päälle.
Sylkäytti syänaloa,
Wärähytti varpahia,
Tahto puheta punanen,
Waikk' oli valkiaverinen.
Eikä sitte ensiyönä
Saanut unta silmillensä,
Ajatteli aikojansa:
"Mikä mielessä Marilla,
Kun ei huolinut minusta,
Waikka kaiken vaivan kanssa
Kannan kalua kokohon!
Minä otan ompelolla,
Takomalla talvikauet,
Weän värkkiä kokohan,
Wielä viljoa metästä,
Ansoistani aikalailla,
Parahite pauloistani,
Satimistani samate."
356—368.
Aina arveli Sameli,
Wielä muisti muinosetki:
"Sinne sortu sormukseni,
Sinne värkkini väheni,
Kaikki kulu kintahani,
Kaikki kenkäni keveni,
Yöjalassa juostessani,
Warsin kauan valvomassa,
Talvikauen tarpoessa.
Sauoin varsin vaikiasti,
Sukset tarttu takkalahan,
Tahon puota pyörtehesen,
Aina mennä ämmän alle."
369—378.
Sitte ensilauantaina
Lähti poika polkemahan,
Walmisti vaeltamahan,
Kylyn jälkehen kylästä.
Juoksi yöllä yksinänsä
Heti kohta Hekkalahan,
Waan ei löytänyt Maria,
Eikä saanut sormustansa —
Mari oli poissa Pulkkilasta
Mennyt morsianverolle.
379—381.
Hakaroipi Haapalaista,
Kulkkuperä kuivettupi,
Pakottaa pahon syäntä.
382-389.
Sitte kuuli korkialta
Saarnastuolista sanoman,
Marin vietävän vihille,
Iän kaiken istumahan,
Asumahan Antin kanssa.
Ain' on haiku Haapalaisen,
Aina yölläki unissa,
Aina päässä päivänäki.
390—393.
Kauan häitä hankittihin,
Monet viikot morsianta,
Suuri aika sulhasmiestä.
Mari sano sulhaselle:
"Joko viimmen joutunemma,
Joko lyönemmä lähöksi;
Toisinaan tulepi konna,
Pylyhousu pöyän päähän,
Isotellen ilkiästi,
Humalaisna hullupäanä,
Tuopi pian tullessansa
Wielä villin viimmesenki,
Kun on ollut ensimmäisnä,
Waan ei virkata mitänä."
404—411.
Wiimmen vietihin vihille,
Päästettihin perjantaina.
Kaikki kulki kahtomahan
Kauan häitä hankituita,
Monen miehen morsianta,
Kuulusinta kukkapäätä,
Suurta riemua suloista,
Suurta viulun vingutusta.
412—116.
Waan ei pojat puoletkana
Mahu salihin sisälle,
Eikä pääse pyörimähän;
Kansa seiso kartanolla,
Alla akkunan pihalla.
417—423.
Annettihin akkunasta
Wiinaryppy vierahille,
Punssikuppi kuhtutuille;
Kaikki tuli tuppurihin,
Nurkkavilpat viimmeseksi,
Että tahtomat tapella
Rannin pojat rantehella.
424—431.
Martti neuo neitosia,
Tykö puhu tyttärille,
Olla loukossa lujassa,
Ett' on kuja kuhtutuilla,
Sola sievästi rakettu.
Kahto sitte kartanolle,
Täällä pojat pyörimässä,
Tanteretta taistelevat.
432—439.
Martti puhu poikasille,
Kovin könnistö köpisi:
"Ettekö luule ensinkänä
Tulevan tilintekoa,
Kun ette siirry sinnemmäksi
Kokonansa kartanosta,
Että pääsisi pihalla
Kuhtuväki kulkemahan."
440—448.
Pojat nakkasit napahan,
Lumipallon palliohon,
Muutamat ne muistelivat
Naurusanoilla Samua:
"Ei ole sattunut Sameli,
Kahtomahan Karjalainen,
Kenpä saattaisi sanoman,
Kulettaisi Köyryojahan;
Siell' on ollut ompelossa."
449—460.
Kulkupoika kuuliainen,
Aivan joutusa jalalta,
Saattapi sanan kylälle,
Kulettapi Köyryojahan:
"Astu heti Anttosehen,
Lähe Launolan kylähän!
Siell' on monta muualtaki,
Sinne on Siikajoelta,
Tullut paljo Paltamosta,
Oulujoelta osannut,
Kyttäriä Tyrnävältä,
Haapajoelta halulla."
461-464.
Taasen säikähti Sameli,
Muoto muualle menepi,
Rupiapi ruskiaksi,
Ohtavierus ouostupi.
465-469.
Pojat penkiltä puhuvat,
Naiset kaikki karsinasta:
"Mik' on tullunna tulonen,
Kosk' ei puhu puolinkana,
Waikk' oli illalla ilonen!"
470—479.
Ajo kyytillä kylähän,
Aina asti Anttoselle.
Sitte kahto kartanolta,
Pian pirtin ikkunasta:
Mari istupi isona,
Pöykkiänä pöyän päässä,
Pää on pantu palmikolla,
Kulta kaulassa kaluna,
Kuultaruunuki rakettu,
Korvat kullankarvaseksi.
480—492.
Puhu vielä Wiion Yrkkö
Muistutteli muien kuulten:
"Onko hyvä Haapalaista,
Kahtoasi kartanolta,
Kun on saanut semmoseksi,
493—502.
Mari kiljasi kivasti:
"Se parahaksi pahalle,
Keskitieksi kehnommalle;
Enkä huoli höyhöstäsi,
Weinaristasi valita,
"Joll' on monta morsianta,
Saattapi satoja olla,
Ellijä enimmät puolet,
Annijaki aikalailla,
Wielä Liisoja lisäksi.
503—506.
Kerran kävi Hekkalassa,
Kulki konna koukkuinensa,
Taisi sillonki takasi
Kyllä kyytillä palata."
507-511.
Niinpä Mari mahtavasti
Kyllä haukku Haapalaista,
Kun ei oikein osannut
Puhutella Pulkkilassa,
Riitan kanssa rinnustella.
512—517.
Wielä naiset naurelivat,
Paljo piiat pilkkasivat:
"Mene syömähän Sameli,
Poika riepu pöyän päähän,
Kun olet selvennyt surusta."
518—526.
Sanopi Sameli riepu:
"Jos oisi köyttä joutavaista,
Jonka sitoisin simuhin,
Solmiaisin suolilleni,
Ettei nälkä näissä häissä
Panisi nyt näin pahasti;
Kun en muistanut kylässä
Syöä iltaista esinnä,
Enkä ottanut evästä.
527—538.
Pääsisin mä piilosalla,
Käyä uunilla osaisin,
Saisin ma pa'asta paistin,
Kupin uunin kukkulalta,
Warkahin vetäisin poies,
Kulettaisin kartanolle
Siinä söisin sormillani,
Kourillani koitteleisin,
Mitä pannussa parasta,
Kosk' ei kanssa kahvelia,
Eikä luona lusikkata,
Pöytäveistä vieressäni."
539—550.
Sitte Wielä viikon päässä
Saneli Sameli riepu,
Ite laulo Launolassa:
"Oisin ottanut emännän,
Kumppalikseni komian,
Warsin sievän vaimokseni
Jok' ois neuonut nevalle,
Talon töihin taivutellut,
Toimitellut tervateille,
Poies vienyt viinateiltä;
Waan jo veivät viekkahammat,
Etevämmät ennättivät.
551—559.
Jo on souttu suoveteni,
Kalalampini kaluttu,
Walkamani vilkutettu.
Jo on souttu — soutakohot —
Selv' on souta souttu ranta,
Ennen tehty tie parempi.
Jo on souttu — soutakohot —
Soleamp' on soutakseni,
Kepeämpi käätäkseni."
Satuja.
1. Paimen ja Ahti.
2. Hepo ja Härkä.