Author: 我
Abstract
We present an online algorithm for the incremental construction of the strong interval tree of a permutation in time and space. The algorithm explicitly tracks the structural changes in the strong interval forest caused by appending a new integer to the permutation. Owing to the slow growth of the inverse Ackermann function, the algorithm is near-optimal with respect to the information-theoretic lower bound. We revisit the basic properties of intervals and the known offline incremental construction, and then show how to convert the offline algorithm into an online one using a data structure for range semigroup queries——a modest but novel contribution.
Keywords: Strong Interval Tree, Sparse Table, Segment Tree, Ackermann Function
MSC2020: 68R05, 68P05, 68W40
1. Introduction
Throughout this paper, closed intervals may be degenerate: when , denotes the singleton . All intervals are over the integers, so with .
Definition 1.1. Let be a permutation.
- A factor of is a contiguous subsequence .
- An interval of is a factor whose values form a consecutive integer set, i.e., for some . Let denote the set of all intervals of .
- A strong interval is an interval such that for every ,
We first record a basic property of intervals.
Lemma 1.1. Let . If , , and , then , , , and are all intervals. Moreover, if we define a partial order on by for all , then either
or
Proof. Write , , , . Assume without loss of generality that . Then and . Since neither nor contains the other, the same holds for and ; hence either or . In the first case,
which gives the desired order. The second case is symmetric.
Intervals correspond to modules in permutation graphs and are central to substitution decomposition theory [2]. Understanding their structure is therefore of combinatorial significance.
Definition 1.2. The strong interval tree of a permutation is the rooted tree whose nodes are the strong intervals, with the parent of a node defined as the shortest strong interval properly containing it. The root is the whole permutation, and the leaves are the unit intervals.
Each node has at most one parent, so the structure is indeed a tree. A non-leaf strong interval is the disjoint union of its children: they are pairwise disjoint by Definition 1.1, and every leaf inside must lie in exactly one child.
Definition 1.3. Order the children of a node from left to right. Let denote the rank of the -th child in the partial order on intervals. Then is a permutation, called the children permutation of .
Children permutations have a special structure.
Lemma 1.2. For a children permutation of length , every proper factor of length at least is either an interval or not——uniformly.
Proof.
Call a comparable partition of if
and
or the reverse chain holds.
Suppose is an interval, neither the whole nor a singleton. Let be the -th child of . Then is not strong, so there exists another interval that overlaps but does not contain . By Definition 1.1 and Lemma 1.1, must be a union of consecutive children, say . If , then is comparable. Repeating this argument forces the entire set to be comparable, meaning is either or .
Nodes of the first type are called linear, and nodes of the second type prime. The strong interval tree gives a complete description of all intervals.
Theorem 1.1. For a linear node with children , every union with and is a non-strong interval. Conversely, every non-strong interval arises in this way from a unique linear node.
Proof. The first direction is immediate. For the converse, let be a non-strong interval, and let be the shortest strong interval containing . Then cannot partially overlap a child of ; otherwise Definition 1.1 would be violated. Hence is a union of consecutive children. Since is not strong, it must be a proper union of at least two children, which forces to be linear.
We now turn to the algorithmic problem: how to construct the strong interval tree efficiently.
2. An Offline Incremental Construction
It is known [3] that the strong interval tree can be constructed in time. In particular, an incremental approach is feasible [4].
Definition 2.1. A maximal interval of a factor is an interval not properly contained in any other interval of that factor.
The maximal intervals of a factor partition it: they are disjoint by Lemma 1.1, and every position belongs to at least one maximal interval.
At step , we have already built the strong interval forest for the maximal intervals of the prefix . We must update this forest to reflect the extension to .
Theorem 2.1. All non-root strong intervals of the current forest remain in the final tree. Only linear roots may be removed.
Proof. Suppose a non-root node is destroyed because a new interval violates Definition 1.1. Then necessarily . Let be the parent of . Then is an interval. Since the child was strong, it must have been the rightmost child of its parent; otherwise would already violate Definition 1.1. By Lemma 1.1, the child is either the largest or smallest among its siblings, so its parent is linear (Lemma 1.2). If it is the largest, then
which implies that the union of with ‘s previous sibling is an interval, contradicting Definition 1.1. The second assertion is clear.
Theorem 2.1 identifies which nodes survive and which are deleted. The next theorem describes the new nodes.
Theorem 2.2. Any new strong interval introduced by appending an element has the form , where is the left endpoint of some original maximal interval.
Proof. A non-strong interval cannot become strong, so any new interval must have right endpoint . If split an original maximal interval, Definition 1.1 would be violated.
Based on these two theorems and a simple fact that all deleted nodes are contained by the new maximal interval, the following algorithm is correct: maintain a stack of maximal intervals, with intervals closer to the right end of stored closer to the top. When inserting , pop the top element , delete it if it is no longer strong, and insert if it is an interval. Repeat until no more strong intervals appear, then push the last inserted node onto the stack as a new maximal interval.
Since is an interval iff , interval tests can be done in time using a -block sparse table [5]. The total number of stack operations is .
Let be an arbitrary factor. The shortest new strong interval containing it is at least , where
In other words, must expand to at least to fill the gaps in . If is an interval, then ; otherwise . Thus, repeatedly replacing by until it stabilizes yields the next new strong interval.
This iterative process can be expressed by the recurrence
where denotes the rightmost index to which the left endpoint must extend in order to cover all values between and .
Then the successor of interval is . Since holds when , this recurrence is equivalent to the previous iteration. The process stops when is not an interval. The values can be computed via the same -block sparse table. However, is a variation of the static RMQ problem with append operations. Fortunately, once a sparse table entry captures a minimum, its value never changes, so can be maintained in time by updating only the affected entries according to the recurrence.
Specifically, let denote the minimum of stored by sparse table, then the recurrence is , which can be represented by a directed acyclic graph where
Modifying the -th element affects and all nodes reachable from it. If we avoid traversing nodes whose value is during the update, the total time complexity is .
The in-block data naturally supports append operations.
3. Online Conversion
To make the incremental construction work in an online setting, range maximum and minimum queries on can be handled in the same way as the maintenance of . The computation of , however, presents a different challenge. Abstractly, we start with an array of length filled with . We then perform replacements: the -th replacement sets some to . Between replacements, range minimum queries may be issued. The -block sparse table is not suitable here because its in-block information does not support arbitrary point updates.
To overcome this limitation, we introduce a data structure that supports static range semigroup queries in preprocessing time and query time, using a more complete DAG structure [6].
Definition 3.1. (Ackermann Function and Its Inverse)
where the superscript denotes iteration. Equivalently,
and
Any closed interval can be partitioned into at most intervals of the form .
Theorem 3.1. For any , there exist
and with such that .
Proof. Define
The sequence must decrease to compensate for the growth of as increases. Since implies , the bound follows. Replacing by repeatedly ensures .
If we use a segment tree to query the minimum over a subsequence, the result is the union of information along a leaf-to-leaf path. Splitting this path at the LCA reduces the problem to considering leaf-to-ancestor paths.
Theorem 3.2. Let denote the height of node (with for leaves), let denote the ancestor of at height , and let denote the path between and . Then the number of paths of the form is .
Proof. By Theorem 3.1, it suffices to consider paths with and . Their total number is bounded by
Thus we can precompute the information along these paths recursively according to the definition of the Ackermann function, using time and space. This can be improved to by applying -blocking while preserving query time per operation.
Moreover, the techniques used for the sparse table also apply to this segment-tree-based structure, as it consists solely of the recurrence relation for the minimum value. Let denote the minimum on , the recurrence is
where s are basic values. It’s DAG structure is easy to see.
Nevertheless, since we need to perform queries on this data structure, the overall complexity of this online incremental method remains .
Acknowledgments
The author is deeply grateful to Prof. Sergei Kalmykov of Academic English Writing for his invaluable guidance on academic writing throughout this paper.
The author thanks UnyieldingTrilobite for insightful discussions on the range semigroup query problem.
The author thanks Querainy for constructive comments that significantly improved this paper.
References
[1] Ir1d, StudyingFather, Tiphereth-A, H-J-Granger, sshwy, countercurrent-time, et al., “The Strong Interval Tree,” OI-wiki. May 13, 2026. [Online]. Available: https://oiwiki.org/ds/divide-combine/ [Accessed: Jul. 16, 2026]
[2] C. Capelle, M. Habib, and F. de Montgolfier, “Graph Decompositions and Factorizing Permutations,” Discrete Mathematics and Theoretical Computer Science, vol. 5, pp. 55-70, 2002. doi: 10.46298/dmtcs.298.
[3] A. Pierrot, “Combinatoire et algorithmique dans les classes de permutations,” Ph.D. dissertation, Université Paris Diderot - Paris 7, Paris, France, 2013.
[4] Chengao Liu, “Basic Interval Data Structure,” WC2019 Participant Presentations, Guangzhou No.2 Middle School, Jan. 26, 2019.
[5] StudyingFather, Ir1d, zhouyuyang2002, Tiphereth-A, AxolotlXD666, c-forrest, et al., “RMQ,” OI-wiki. Jun. 20, 2026. [Online]. Available: https://oiwiki.org/topic/rmq/ [Accessed: Jul. 31, 2026]
[6] UnyieldingTrilobite, “Segment Tree, Ackermann, Blocking,” Luogu. Oct. 26, 2024. [Online]. Available: https://www.luogu.com/article/on6jtb2m [Accessed: Jan. 20, 2026]