See wikipedia and here for the definition of Kolakoski sequence. I recently notice a slide made by Prof. Richard P. Brent, which states that we can calculate the frequency of a letter within the first $n$ terms under sublinear complexity. But I encounter some difficulties during implementation. May I ask how to generate the lookup table in $O(2^{d_{max}})$? Can the conclusion be extended to other Kolakoski-type sequences? Thanks.
2026-03-25 15:56:46.1774454206
Kolakoski sequence
190 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
There are 1 best solutions below
Related Questions in SEQUENCES-AND-SERIES
- How to show that $k < m_1+2$?
- Justify an approximation of $\sum_{n=1}^\infty G_n/\binom{\frac{n}{2}+\frac{1}{2}}{\frac{n}{2}}$, where $G_n$ denotes the Gregory coefficients
- Negative Countdown
- Calculating the radius of convergence for $\sum _{n=1}^{\infty}\frac{\left(\sqrt{ n^2+n}-\sqrt{n^2+1}\right)^n}{n^2}z^n$
- Show that the sequence is bounded below 3
- A particular exercise on convergence of recursive sequence
- Proving whether function-series $f_n(x) = \frac{(-1)^nx}n$
- Powers of a simple matrix and Catalan numbers
- Convergence of a rational sequence to a irrational limit
- studying the convergence of a series:
Related Questions in INTEGERS
- Name of Theorem for Coloring of $\{1, \dots, n\}$
- Which sets of base 10 digits have the property that, for every $n$, there is a $n$-digit number made up of these digits that is divisible by $5^n$?
- Ring of remainders definition
- Proof of well-ordering property
- Compute a division with integer and fractional part
- Solving for 4 variables using only 2 equations
- For any natural numbers a, b, c, d if a*b = c*d is it possible that a + b + c + d is prime number
- Can I say this :$e^{{(294204)}^{1/11}}-{(294204)}^{1/11}$ integer number or almost integer?
- Pack two fractional values into a single integer while preserving a total order
- What will be the difference?
Trending Questions
- Induction on the number of equations
- How to convince a math teacher of this simple and obvious fact?
- Find $E[XY|Y+Z=1 ]$
- Refuting the Anti-Cantor Cranks
- What are imaginary numbers?
- Determine the adjoint of $\tilde Q(x)$ for $\tilde Q(x)u:=(Qu)(x)$ where $Q:U→L^2(Ω,ℝ^d$ is a Hilbert-Schmidt operator and $U$ is a Hilbert space
- Why does this innovative method of subtraction from a third grader always work?
- How do we know that the number $1$ is not equal to the number $-1$?
- What are the Implications of having VΩ as a model for a theory?
- Defining a Galois Field based on primitive element versus polynomial?
- Can't find the relationship between two columns of numbers. Please Help
- Is computer science a branch of mathematics?
- Is there a bijection of $\mathbb{R}^n$ with itself such that the forward map is connected but the inverse is not?
- Identification of a quadrilateral as a trapezoid, rectangle, or square
- Generator of inertia group in function field extension
Popular # Hahtags
second-order-logic
numerical-methods
puzzle
logic
probability
number-theory
winding-number
real-analysis
integration
calculus
complex-analysis
sequences-and-series
proof-writing
set-theory
functions
homotopy-theory
elementary-number-theory
ordinary-differential-equations
circles
derivatives
game-theory
definite-integrals
elementary-set-theory
limits
multivariable-calculus
geometry
algebraic-number-theory
proof-verification
partial-derivative
algebra-precalculus
Popular Questions
- What is the integral of 1/x?
- How many squares actually ARE in this picture? Is this a trick question with no right answer?
- Is a matrix multiplied with its transpose something special?
- What is the difference between independent and mutually exclusive events?
- Visually stunning math concepts which are easy to explain
- taylor series of $\ln(1+x)$?
- How to tell if a set of vectors spans a space?
- Calculus question taking derivative to find horizontal tangent line
- How to determine if a function is one-to-one?
- Determine if vectors are linearly independent
- What does it mean to have a determinant equal to zero?
- Is this Batman equation for real?
- How to find perpendicular vector to another vector?
- How to find mean and median from histogram
- How many sides does a circle have?
To generate the lookup tables in $O(2^{d_\max})$, or, equivalently, to generate the $d$th table in $O(2^d)$, you need first to generate the tables for the lesser $d$ and then use them when generating the $d$th table just in the same way as you then use all the prepared tables when generating a term of Kolakoski sequence.
I have implemented a demo which shows both lazy $O(3^d)$ and fast $O(2^d)$ generation methods. Disclaimers: it's written in Python, so it's too slow for practical use with large $n$; also, there are some inaccuracies that seem to make it rather $O(d2^d)$ than $O(2^d)$.
As for other Kolakoski-type sequences, assuming you mean sequences like the ones referenced in the paragraph entitled "Kolakoski-type sequences using other seeds than (1,2)" in OEIS A2, yes, the same algorithm can work for them, but you'll lose the possibility to make use of bit operations. You still can encode rows as sequences of bits, but you'll have to implement operations with them using cycles instead of atomic binary operations, which will slightly worsen the complexity of the algorithm.
In general, when analyzing a row of the table shown in Brent's slides, you need to keep track how much times will a value in every column occur again before it changes. For the usual (1,2) Kolakoski sequence, this information can naturally be stored as a sequence of bits, partially obtained from the sequence of bits encoding the row itself by a bit shift by 1 (because of the definition of the Kolakoski sequence: every number is also a run length). For generic Kolakoski-type sequence, this bit tricks aren't available any more, so it may be convenient to store these run lengths as an array of
ints/bytes/u8s; you don't have to worry about the space it takes. But the information about the row itself is used in the lookup tables (both as keys and as parts of values), so you have to make it compact. If your sequence has only two different alternating values, like in OEIS A064353 or A071820 (or in the usual Kolakoski sequence), then you can still store the current value in a single bit, but with different correspondence than $0\to1,1\to2$; if there are three or four values changing by a cycle, like in OEIS A079729 or A079730, then you'll have to use two bits to store the current value (so for the (1,2,3) variant, say, the row $1, 1, 3, 3, 2$ can be encoded as0b01_10_10_00_00); for five to eight values, you'll need three bits, and so on. You'll have to implement functions which (a) check the value of a given (0th, 1st, 2nd...) group of bits (= term in the row of the table) and interpret it as one of the numbers the sequence consists of, and (b) set the value of a given group of bits.