A deterministic sublinear-time nonadaptive algorithm for metric 111-median selection

Ching-Lueh Chang 111Department of Computer Science and Engineering, Yuan Ze University, Taoyuan, Taiwan. Email: clchang@saturn.yzu.edu.tw 222Innovation Center for Big Data and Digital Convergence, Yuan Ze University, Taoyuan, Taiwan. 333Supported in part by the Ministry of Science and Technology of Taiwan under grant 103-2221-E-155-026-MY2.
Abstract

We give a deterministic O​(h​n1+1/h)π‘‚β„Žsuperscript𝑛11β„ŽO(hn^{1+1/h})-time (2​h)2β„Ž(2h)-approximation nonadaptive algorithm for 111-median selection in n𝑛n-point metric spaces, where hβˆˆβ„€+βˆ–{1}β„Žsuperscriptβ„€1h\in\mathbb{Z}^{+}\setminus\{1\} is arbitrary. Our proof generalizes that of Chang [2].

1 Introduction

A metric space (M,d)𝑀𝑑(M,d) is a nonempty set M𝑀M endowed with a function d:MΓ—Mβ†’[ 0,∞):𝑑→𝑀𝑀 0d\colon M\times M\to[\,0,\infty\,) such that for all xπ‘₯x, y𝑦y, z∈M𝑧𝑀z\in M,

  • β€’

    d​(x,y)=0𝑑π‘₯𝑦0d(x,y)=0 if and only if x=yπ‘₯𝑦x=y,

  • β€’

    d​(x,y)=d​(y,x)𝑑π‘₯𝑦𝑑𝑦π‘₯d(x,y)=d(y,x), and

  • β€’

    d​(x,y)+d​(y,z)β‰₯d​(x,z)𝑑π‘₯𝑦𝑑𝑦𝑧𝑑π‘₯𝑧d(x,y)+d(y,z)\geq d(x,z) (triangle inequality).

The metric 111-median problem asks for a point in an n𝑛n-point metric space (M,d)𝑀𝑑(M,d) with the minimum average distance to other points. For cβ‰₯1𝑐1c\geq 1, a point p^∈M^𝑝𝑀\hat{p}\in M is said to be c𝑐c-approximate for metric 111-median if

βˆ‘x∈Md​(p^,x)≀cβ‹…minp∈Mβ€‹βˆ‘x∈Md​(p,x).subscriptπ‘₯𝑀𝑑^𝑝π‘₯⋅𝑐subscript𝑝𝑀subscriptπ‘₯𝑀𝑑𝑝π‘₯\sum_{x\in M}\,d\left(\hat{p},x\right)\leq c\cdot\min_{p\in M}\,\sum_{x\in M}\,d\left(p,x\right).

An algorithm for metric 111-median is nonadaptive if the sequence of distances that it inspects depends only on M𝑀M but not on d𝑑d. Because there are n​(nβˆ’1)/2𝑛𝑛12n(n-1)/2 nonzero distances, β€œsublinear-time” will mean β€œo​(n2)π‘œsuperscript𝑛2o(n^{2})-time.”

Indyk [5, 6] shows that metric 111-median has a Monte-Carlo O​(n/Ο΅2)𝑂𝑛superscriptitalic-Ο΅2O(n/\epsilon^{2})-time (1+Ο΅)1italic-Ο΅(1+\epsilon)-approximation algorithm for each Ο΅>0italic-Ο΅0\epsilon>0. In ℝDsuperscriptℝ𝐷\mathbb{R}^{D}, where Dβ‰₯1𝐷1D\geq 1, metric 111-median has a Monte-Carlo O​(2poly​(1/Ο΅)​D)𝑂superscript2poly1italic-ϡ𝐷O(2^{\text{poly}(1/\epsilon)}D)-time (1+Ο΅)1italic-Ο΅(1+\epsilon)-approximation algorithm for all Ο΅>0italic-Ο΅0\epsilon>0 [7]. Many other algorithms are known for kπ‘˜k-median selection [4, 7, 1]. For example, Guha et al. [4] give a deterministic, O​(n1+Ο΅)𝑂superscript𝑛1italic-Ο΅O(n^{1+\epsilon})-time, O​(nΟ΅)𝑂superscript𝑛italic-Ο΅O(n^{\epsilon})-space, 2O​(1/Ο΅)superscript2𝑂1italic-Ο΅2^{O(1/\epsilon)}-approximation and one-pass algorithm as well as a Monte-Carlo algorithm for kπ‘˜k-median selection in metric spaces, where Ο΅>0italic-Ο΅0\epsilon>0.

We show that metric 111-median has a deterministic O​(h​n1+1/h)π‘‚β„Žsuperscript𝑛11β„ŽO(hn^{1+1/h})-time (2​h)2β„Ž(2h)-approximation nonadaptive algorithm for all hβˆˆβ„€+βˆ–{1}β„Žsuperscriptβ„€1h\in\mathbb{Z}^{+}\setminus\{1\}, generalizing the following theorems:

Theorem 1 ([2]).

Metric 111-median has a deterministic O​(n1.5)𝑂superscript𝑛1.5O(n^{1.5})-time 444-approximation nonadaptive algorithm.

Theorem 2 ([8]).

For each hβˆˆβ„€+βˆ–{1}β„Žsuperscriptβ„€1h\in\mathbb{Z}^{+}\setminus\{1\}, metric 111-median has a deterministic O​(h​n1+1/h)π‘‚β„Žsuperscript𝑛11β„ŽO(hn^{1+1/h})-time (2​h)2β„Ž(2h)-approximation (adaptive) algorithm.444The time complexity of O​(h​n1+1/h)π‘‚β„Žsuperscript𝑛11β„ŽO(hn^{1+1/h})is originally presented as O​(n1+1/h)𝑂superscript𝑛11β„ŽO(n^{1+1/h})because hβ„Žhis independent of n𝑛n. We include the O​(h)π‘‚β„ŽO(h)factor, which is implicit in the original proof, for ease of comparison.

When n𝑛n is a perfect square and h=2β„Ž2h=2, our proof is equivalent to that of Theorem 1 [2]. Chang [3] shows that metric 111-median has no deterministic o​(n2)π‘œsuperscript𝑛2o(n^{2})-query (4βˆ’Ξ©β€‹(1))4Ξ©1(4-\Omega(1))-approximation algorithms (where an algorithm’s query complexity is the number of distances that it inspects). So the approximation ratio of 444 in Theorem 1 cannot be improved to a smaller constant.

2 Our algorithm

Let ({0,1,…,nβˆ’1},d)01…𝑛1𝑑(\{0,1,\ldots,n-1\},d) be a metric space, hβˆˆβ„€+βˆ–{1}β„Žsuperscriptβ„€1h\in\mathbb{Z}^{+}\setminus\{1\} and t=⌈n1/hβŒ‰π‘‘superscript𝑛1β„Žt=\lceil n^{1/h}\rceil. For all j∈{0,1,…,nβˆ’1}𝑗01…𝑛1j\in\{0,1,\ldots,n-1\}, denote the (unique) t𝑑t-ary representation of j𝑗j by

(shβˆ’1​(j),shβˆ’2​(j),…,s0​(j))∈{0,1,…,tβˆ’1}h,subscriptπ‘ β„Ž1𝑗subscriptπ‘ β„Ž2𝑗…subscript𝑠0𝑗superscript01…𝑑1β„Ž\displaystyle\left(s_{h-1}(j),s_{h-2}(j),\ldots,s_{0}(j)\right)\in\left\{0,1,\ldots,t-1\right\}^{h},

i.e.,

βˆ‘β„“=0hβˆ’1sℓ​(j)β‹…tβ„“=j.superscriptsubscriptβ„“0β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑗\displaystyle\sum_{\ell=0}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}=j.(1)

For all i𝑖i, j∈{0,1,…,nβˆ’1}𝑗01…𝑛1j\in\{0,1,\ldots,n-1\},

d~​(i,i+jmodn)=def.βˆ‘k=0hβˆ’1d​(i+βˆ‘β„“=hβˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn,i+βˆ‘β„“=hβˆ’1βˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn).superscriptdef.~𝑑𝑖modulo𝑖𝑗𝑛superscriptsubscriptπ‘˜0β„Ž1𝑑modulo𝑖superscriptsubscriptβ„“β„Žπ‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛modulo𝑖superscriptsubscriptβ„“β„Ž1π‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛\displaystyle\tilde{d}\left(i,i+j\bmod{n}\right)\stackrel{{\scriptstyle\text{def.}}}{{=}}\sum_{k=0}^{h-1}\,d\left(i+\sum_{\ell=h-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n},i+\sum_{\ell=h-1-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n}\right).(2)

By convention, empty sums vanish, e.g., βˆ‘β„“=hhβˆ’1sℓ​(j)β‹…tβ„“=0superscriptsubscriptβ„“β„Žβ„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ0\sum_{\ell=h}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}=0.

Lemma 3.

For all i𝑖i, j∈{0,1,…,nβˆ’1}𝑗01…𝑛1j\in\{0,1,\ldots,n-1\},

d​(i,i+jmodn)≀d~​(i,i+jmodn).𝑑𝑖modulo𝑖𝑗𝑛~𝑑𝑖modulo𝑖𝑗𝑛d\left(i,i+j\bmod{n}\right)\leq\tilde{d}\left(i,i+j\bmod{n}\right).
Proof.

By equation (2) and the triangle inequality for d𝑑d,

d~​(i,i+jmodn)β‰₯d​(i,i+βˆ‘β„“=0hβˆ’1sℓ​(j)β‹…tβ„“modn).~𝑑𝑖modulo𝑖𝑗𝑛𝑑𝑖modulo𝑖superscriptsubscriptβ„“0β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛\tilde{d}\left(i,i+j\bmod{n}\right)\geq d\left(i,i+\sum_{\ell=0}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n}\right).

This and equation (1) complete the proof. ∎

Lemma 4.

For all α∈{0,1,…,nβˆ’1}𝛼01…𝑛1\alpha\in\{0,1,\ldots,n-1\} with

βˆ‘j=0nβˆ’1d~​(Ξ±,Ξ±+jmodn)=mini=0nβˆ’1β€‹βˆ‘j=0nβˆ’1d~​(i,i+jmodn),superscriptsubscript𝑗0𝑛1~𝑑𝛼modulo𝛼𝑗𝑛superscriptsubscript𝑖0𝑛1superscriptsubscript𝑗0𝑛1~𝑑𝑖modulo𝑖𝑗𝑛\displaystyle\sum_{j=0}^{n-1}\,\tilde{d}\left(\alpha,\alpha+j\bmod{n}\right)=\min_{i=0}^{n-1}\,\sum_{j=0}^{n-1}\,\tilde{d}\left(i,i+j\bmod{n}\right),(3)

we have

βˆ‘j=0nβˆ’1d​(Ξ±,j)≀2​hβ‹…mini=0nβˆ’1β€‹βˆ‘j=0nβˆ’1d​(i,j).superscriptsubscript𝑗0𝑛1𝑑𝛼𝑗⋅2β„Žsuperscriptsubscript𝑖0𝑛1superscriptsubscript𝑗0𝑛1𝑑𝑖𝑗\displaystyle\sum_{j=0}^{n-1}\,d\left(\alpha,j\right)\leq 2h\cdot\min_{i=0}^{n-1}\,\sum_{j=0}^{n-1}\,d\left(i,j\right).(4)
Proof.

Let 𝒖𝒖\boldsymbol{u} be a uniformly random element of {0,1,…,nβˆ’1}01…𝑛1\{0,1,\ldots,n-1\} and

iβ€²=argmini=0nβˆ’1βˆ‘j=0nβˆ’1d​(i,j),superscript𝑖′superscriptsubscriptargmin𝑖0𝑛1superscriptsubscript𝑗0𝑛1𝑑𝑖𝑗\displaystyle i^{\prime}=\mathop{\mathrm{argmin}}_{i=0}^{n-1}\,\sum_{j=0}^{n-1}\,d\left(i,j\right),(5)

breaking ties arbitrarily. It is easy to see that

βˆ‘j=0nβˆ’1d​(Ξ±,j)=βˆ‘j=0nβˆ’1d​(Ξ±,Ξ±+jmodn).superscriptsubscript𝑗0𝑛1𝑑𝛼𝑗superscriptsubscript𝑗0𝑛1𝑑𝛼modulo𝛼𝑗𝑛\displaystyle\sum_{j=0}^{n-1}\,d\left(\alpha,j\right)=\sum_{j=0}^{n-1}\,d\left(\alpha,\alpha+j\bmod{n}\right).

Furthermore,

βˆ‘j=0nβˆ’1d​(Ξ±,Ξ±+jmodn)superscriptsubscript𝑗0𝑛1𝑑𝛼modulo𝛼𝑗𝑛\displaystyle\sum_{j=0}^{n-1}\,d\left(\alpha,\alpha+j\bmod{n}\right)≀Lemma 3superscriptLemma 3\displaystyle\stackrel{{\scriptstyle\text{Lemma~{}\ref{pseudodistanceislarger}}}}{{\leq}}βˆ‘j=0nβˆ’1d~​(Ξ±,Ξ±+jmodn)superscriptsubscript𝑗0𝑛1~𝑑𝛼modulo𝛼𝑗𝑛\displaystyle\sum_{j=0}^{n-1}\,\tilde{d}\left(\alpha,\alpha+j\bmod{n}\right)
≀equation (3)superscriptequation (3)\displaystyle\stackrel{{\scriptstyle\text{equation~{}(\ref{theoptimalpointwithrespecttopseudodistance})}}}{{\leq}}E[βˆ‘j=0nβˆ’1d~​(𝒖,𝒖+jmodn)].Edelimited-[]superscriptsubscript𝑗0𝑛1~𝑑𝒖modulo𝒖𝑗𝑛\displaystyle\mathop{\mathrm{E}}\left[\,\sum_{j=0}^{n-1}\,\tilde{d}\left(\boldsymbol{u},\boldsymbol{u}+j\bmod{n}\right)\,\right].

By equation (2),

E[βˆ‘j=0nβˆ’1d~​(𝒖,𝒖+jmodn)]Edelimited-[]superscriptsubscript𝑗0𝑛1~𝑑𝒖modulo𝒖𝑗𝑛\displaystyle\mathop{\mathrm{E}}\left[\,\sum_{j=0}^{n-1}\,\tilde{d}\left(\boldsymbol{u},\boldsymbol{u}+j\bmod{n}\right)\,\right]
=\displaystyle=E[βˆ‘j=0nβˆ’1βˆ‘k=0hβˆ’1d​(𝒖+βˆ‘β„“=hβˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn,𝒖+βˆ‘β„“=hβˆ’1βˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn)].Edelimited-[]superscriptsubscript𝑗0𝑛1superscriptsubscriptπ‘˜0β„Ž1𝑑modulo𝒖superscriptsubscriptβ„“β„Žπ‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛modulo𝒖superscriptsubscriptβ„“β„Ž1π‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛\displaystyle\mathop{\mathrm{E}}\left[\,\sum_{j=0}^{n-1}\,\sum_{k=0}^{h-1}\,d\left(\boldsymbol{u}+\sum_{\ell=h-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n},\boldsymbol{u}+\sum_{\ell=h-1-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n}\right)\,\right].

Finally,

E[βˆ‘j=0nβˆ’1βˆ‘k=0hβˆ’1d​(𝒖+βˆ‘β„“=hβˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn,𝒖+βˆ‘β„“=hβˆ’1βˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn)]Edelimited-[]superscriptsubscript𝑗0𝑛1superscriptsubscriptπ‘˜0β„Ž1𝑑modulo𝒖superscriptsubscriptβ„“β„Žπ‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛modulo𝒖superscriptsubscriptβ„“β„Ž1π‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛\displaystyle\mathop{\mathrm{E}}\left[\,\sum_{j=0}^{n-1}\,\sum_{k=0}^{h-1}\,d\left(\boldsymbol{u}+\sum_{\ell=h-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n},\boldsymbol{u}+\sum_{\ell=h-1-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n}\right)\,\right](6)
≀\displaystyle\leqE[βˆ‘j=0nβˆ’1βˆ‘k=0hβˆ’1d​(iβ€²,𝒖+βˆ‘β„“=hβˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn)+d​(iβ€²,𝒖+βˆ‘β„“=hβˆ’1βˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn)]Edelimited-[]superscriptsubscript𝑗0𝑛1superscriptsubscriptπ‘˜0β„Ž1𝑑superscript𝑖′modulo𝒖superscriptsubscriptβ„“β„Žπ‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛𝑑superscript𝑖′modulo𝒖superscriptsubscriptβ„“β„Ž1π‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛\displaystyle\mathop{\mathrm{E}}\left[\,\sum_{j=0}^{n-1}\,\sum_{k=0}^{h-1}\,d\left(i^{\prime},\boldsymbol{u}+\sum_{\ell=h-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n}\right)+d\left(i^{\prime},\boldsymbol{u}+\sum_{\ell=h-1-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n}\right)\,\right]
=\displaystyle=βˆ‘j=0nβˆ’1βˆ‘k=0hβˆ’1E[d​(iβ€²,𝒖+βˆ‘β„“=hβˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn)]+E[d​(iβ€²,𝒖+βˆ‘β„“=hβˆ’1βˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn)]superscriptsubscript𝑗0𝑛1superscriptsubscriptπ‘˜0β„Ž1Edelimited-[]𝑑superscript𝑖′modulo𝒖superscriptsubscriptβ„“β„Žπ‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛Edelimited-[]𝑑superscript𝑖′modulo𝒖superscriptsubscriptβ„“β„Ž1π‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛\displaystyle\sum_{j=0}^{n-1}\,\sum_{k=0}^{h-1}\,\mathop{\mathrm{E}}\left[\,d\left(i^{\prime},\boldsymbol{u}+\sum_{\ell=h-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n}\right)\,\right]+\mathop{\mathrm{E}}\left[\,d\left(i^{\prime},\boldsymbol{u}+\sum_{\ell=h-1-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n}\right)\,\right]
=\displaystyle=βˆ‘j=0nβˆ’1βˆ‘k=0hβˆ’1(E[d​(iβ€²,𝒖)]+E[d​(iβ€²,𝒖)])superscriptsubscript𝑗0𝑛1superscriptsubscriptπ‘˜0β„Ž1Edelimited-[]𝑑superscript𝑖′𝒖Edelimited-[]𝑑superscript𝑖′𝒖\displaystyle\sum_{j=0}^{n-1}\,\sum_{k=0}^{h-1}\,\left(\mathop{\mathrm{E}}\left[\,d\left(i^{\prime},\boldsymbol{u}\right)\,\right]+\mathop{\mathrm{E}}\left[\,d\left(i^{\prime},\boldsymbol{u}\right)\,\right]\right)
=\displaystyle=2​n​hβ‹…E[d​(iβ€²,𝒖)],β‹…2π‘›β„ŽEdelimited-[]𝑑superscript𝑖′𝒖\displaystyle 2nh\cdot\mathop{\mathrm{E}}\left[\,d\left(i^{\prime},\boldsymbol{u}\right)\,\right],

where the inequality follows from the triangle inequality for d𝑑d, and the second-to-last equality is true because 𝒖+βˆ‘β„“=hβˆ’khβˆ’1sℓ​(j)β‹…tβ„“modnmodulo𝒖superscriptsubscriptβ„“β„Žπ‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛\boldsymbol{u}+\sum_{\ell=h-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n} distributes uniformly at random over {0,1,…,nβˆ’1}01…𝑛1\{0,1,\ldots,n-1\} for any j∈{0,1,…,nβˆ’1}𝑗01…𝑛1j\in\{0,1,\ldots,n-1\} and k∈{0,1,…,h}π‘˜01β€¦β„Žk\in\{0,1,\ldots,h\}. Inequalities (5)–(6) imply inequality (4). ∎

For a predicate P𝑃P, let χ​[P]=1πœ’delimited-[]𝑃1\chi[\,P\,]=1 if P𝑃P is true and χ​[P]=0πœ’delimited-[]𝑃0\chi[\,P\,]=0 otherwise. Define (shβˆ’1β€²,shβˆ’2β€²,…,s0β€²)∈{0,1,…,tβˆ’1}hsubscriptsuperscriptπ‘ β€²β„Ž1subscriptsuperscriptπ‘ β€²β„Ž2…subscriptsuperscript𝑠′0superscript01…𝑑1β„Ž(s^{\prime}_{h-1},s^{\prime}_{h-2},\ldots,s^{\prime}_{0})\in\{0,1,\ldots,t-1\}^{h} to be the t𝑑t-ary representation of nβˆ’1𝑛1n-1. So βˆ‘r=0hβˆ’1srβ€²β‹…tr=nβˆ’1superscriptsubscriptπ‘Ÿ0β„Ž1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿπ‘›1\sum_{r=0}^{h-1}\,s^{\prime}_{r}\cdot t^{r}=n-1. For i∈{0,1,…,nβˆ’1}𝑖01…𝑛1i\in\{0,1,\ldots,n-1\} and m∈{0,1,…,hβˆ’1}π‘š01β€¦β„Ž1m\in\{0,1,\ldots,h-1\},

f​(i,m)π‘“π‘–π‘š\displaystyle f\left(i,m\right)=def.superscriptdef.\displaystyle\stackrel{{\scriptstyle\text{def.}}}{{=}}βˆ‘sm,smβˆ’1,…,s0=0tβˆ’1χ​[βˆ‘r=0msrβ‹…trβ‰€βˆ‘r=0msrβ€²β‹…tr]superscriptsubscriptsubscriptπ‘ π‘šsubscriptπ‘ π‘š1…subscript𝑠00𝑑1πœ’delimited-[]superscriptsubscriptπ‘Ÿ0π‘šβ‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿsuperscriptsubscriptπ‘Ÿ0π‘šβ‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\displaystyle\sum_{s_{m},s_{m-1},\ldots,s_{0}=0}^{t-1}\,\chi\left[\sum_{r=0}^{m}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m}\,s^{\prime}_{r}\cdot t^{r}\right](7)
β‹…β‹…\displaystyle\cdotβˆ‘k=0md​(i+βˆ‘β„“=m+1βˆ’kmsβ„“β‹…tβ„“modn,i+βˆ‘β„“=mβˆ’kmsβ„“β‹…tβ„“modn),superscriptsubscriptπ‘˜0π‘šπ‘‘modulo𝑖superscriptsubscriptβ„“π‘š1π‘˜π‘šβ‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛modulo𝑖superscriptsubscriptβ„“π‘šπ‘˜π‘šβ‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛\displaystyle\sum_{k=0}^{m}\,d\left(i+\sum_{\ell=m+1-k}^{m}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+\sum_{\ell=m-k}^{m}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right),
g​(i,m)π‘”π‘–π‘š\displaystyle g\left(i,m\right)=def.superscriptdef.\displaystyle\stackrel{{\scriptstyle\text{def.}}}{{=}}βˆ‘sm,smβˆ’1,…,s0=0tβˆ’1βˆ‘k=0md​(i+βˆ‘β„“=m+1βˆ’kmsβ„“β‹…tβ„“modn,i+βˆ‘β„“=mβˆ’kmsβ„“β‹…tβ„“modn).superscriptsubscriptsubscriptπ‘ π‘šsubscriptπ‘ π‘š1…subscript𝑠00𝑑1superscriptsubscriptπ‘˜0π‘šπ‘‘modulo𝑖superscriptsubscriptβ„“π‘š1π‘˜π‘šβ‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛modulo𝑖superscriptsubscriptβ„“π‘šπ‘˜π‘šβ‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛\displaystyle\sum_{s_{m},s_{m-1},\ldots,s_{0}=0}^{t-1}\,\sum_{k=0}^{m}\,d\left(i+\sum_{\ell=m+1-k}^{m}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+\sum_{\ell=m-k}^{m}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right).\,\,\,\,\,\,\,\,\,\,(8)

Clearly,

f​(i,0)𝑓𝑖0\displaystyle f\left(i,0\right)=\displaystyle=βˆ‘s0=0s0β€²d​(i,i+s0modn),superscriptsubscriptsubscript𝑠00subscriptsuperscript𝑠′0𝑑𝑖modulo𝑖subscript𝑠0𝑛\displaystyle\sum_{s_{0}=0}^{s^{\prime}_{0}}\,d\left(i,i+s_{0}\bmod{n}\right),(9)
g​(i,0)𝑔𝑖0\displaystyle g\left(i,0\right)=\displaystyle=βˆ‘s0=0tβˆ’1d​(i,i+s0modn).superscriptsubscriptsubscript𝑠00𝑑1𝑑𝑖modulo𝑖subscript𝑠0𝑛\displaystyle\sum_{s_{0}=0}^{t-1}\,d\left(i,i+s_{0}\bmod{n}\right).(10)
Lemma 5.

For all i∈{0,1,…,nβˆ’1}𝑖01…𝑛1i\in\{0,1,\ldots,n-1\},

f​(i,hβˆ’1)=βˆ‘j=0nβˆ’1d~​(i,i+jmodn).π‘“π‘–β„Ž1superscriptsubscript𝑗0𝑛1~𝑑𝑖modulo𝑖𝑗𝑛\displaystyle f\left(i,h-1\right)=\sum_{j=0}^{n-1}\,\tilde{d}\left(i,i+j\bmod{n}\right).
Proof.

As βˆ‘r=0hβˆ’1srβ€²β‹…tr=nβˆ’1superscriptsubscriptπ‘Ÿ0β„Ž1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿπ‘›1\sum_{r=0}^{h-1}\,s^{\prime}_{r}\cdot t^{r}=n-1,

f​(i,hβˆ’1)π‘“π‘–β„Ž1\displaystyle f\left(i,h-1\right)=\displaystyle=βˆ‘shβˆ’1,shβˆ’2,…,s0=0tβˆ’1χ​[βˆ‘r=0hβˆ’1srβ‹…tr≀nβˆ’1]superscriptsubscriptsubscriptπ‘ β„Ž1subscriptπ‘ β„Ž2…subscript𝑠00𝑑1πœ’delimited-[]superscriptsubscriptπ‘Ÿ0β„Ž1β‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿπ‘›1\displaystyle\sum_{s_{h-1},s_{h-2},\ldots,s_{0}=0}^{t-1}\,\chi\left[\,\sum_{r=0}^{h-1}\,s_{r}\cdot t^{r}\leq n-1\,\right](11)
β‹…β‹…\displaystyle\cdotβˆ‘k=0hβˆ’1d​(i+βˆ‘β„“=hβˆ’khβˆ’1sβ„“β‹…tβ„“modn,i+βˆ‘β„“=hβˆ’1βˆ’khβˆ’1sβ„“β‹…tβ„“modn).superscriptsubscriptπ‘˜0β„Ž1𝑑modulo𝑖superscriptsubscriptβ„“β„Žπ‘˜β„Ž1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛modulo𝑖superscriptsubscriptβ„“β„Ž1π‘˜β„Ž1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛\displaystyle\sum_{k=0}^{h-1}\,d\left(i+\sum_{\ell=h-k}^{h-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+\sum_{\ell=h-1-k}^{h-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right).\,\,\,\,\,

By the existence and uniqueness of a t𝑑t-ary representation of each j∈{0,1,…,nβˆ’1}𝑗01…𝑛1j\in\{0,1,\ldots,n-1\},

βˆ‘j=0nβˆ’1βˆ‘k=0hβˆ’1d​(i+βˆ‘β„“=hβˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn,i+βˆ‘β„“=hβˆ’1βˆ’khβˆ’1sℓ​(j)β‹…tβ„“modn)superscriptsubscript𝑗0𝑛1superscriptsubscriptπ‘˜0β„Ž1𝑑modulo𝑖superscriptsubscriptβ„“β„Žπ‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛modulo𝑖superscriptsubscriptβ„“β„Ž1π‘˜β„Ž1β‹…subscript𝑠ℓ𝑗superscript𝑑ℓ𝑛\displaystyle\sum_{j=0}^{n-1}\,\sum_{k=0}^{h-1}\,d\left(i+\sum_{\ell=h-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n},i+\sum_{\ell=h-1-k}^{h-1}\,s_{\ell}(j)\cdot t^{\ell}\bmod{n}\right)(12)
=\displaystyle=βˆ‘shβˆ’1,shβˆ’2,…,s0=0tβˆ’1χ​[βˆ‘r=0hβˆ’1srβ‹…tr≀nβˆ’1]superscriptsubscriptsubscriptπ‘ β„Ž1subscriptπ‘ β„Ž2…subscript𝑠00𝑑1πœ’delimited-[]superscriptsubscriptπ‘Ÿ0β„Ž1β‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿπ‘›1\displaystyle\sum_{s_{h-1},s_{h-2},\ldots,s_{0}=0}^{t-1}\,\chi\left[\,\sum_{r=0}^{h-1}\,s_{r}\cdot t^{r}\leq n-1\,\right]
β‹…β‹…\displaystyle\cdotβˆ‘k=0hβˆ’1d​(i+βˆ‘β„“=hβˆ’khβˆ’1sβ„“β‹…tβ„“modn,i+βˆ‘β„“=hβˆ’1βˆ’khβˆ’1sβ„“β‹…tβ„“modn).superscriptsubscriptπ‘˜0β„Ž1𝑑modulo𝑖superscriptsubscriptβ„“β„Žπ‘˜β„Ž1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛modulo𝑖superscriptsubscriptβ„“β„Ž1π‘˜β„Ž1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛\displaystyle\sum_{k=0}^{h-1}\,d\left(i+\sum_{\ell=h-k}^{h-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+\sum_{\ell=h-1-k}^{h-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right).

Equations (2) and (11)–(12) complete the proof. ∎

Lemma 6.

For all i∈{0,1,…,nβˆ’1}𝑖01…𝑛1i\in\{0,1,\ldots,n-1\} and m∈{1,2,…,hβˆ’1}π‘š12β€¦β„Ž1m\in\{1,2,\ldots,h-1\},

g​(i,m)π‘”π‘–π‘š\displaystyle g\left(i,m\right)=\displaystyle=tmβ€‹βˆ‘sm=0tβˆ’1d​(i,i+smβ‹…tmmodn)superscriptπ‘‘π‘šsuperscriptsubscriptsubscriptπ‘ π‘š0𝑑1𝑑𝑖modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›\displaystyle t^{m}\sum_{s_{m}=0}^{t-1}\,d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)
+\displaystyle+βˆ‘sm=0tβˆ’1g​(i+smβ‹…tmmodn,mβˆ’1).superscriptsubscriptsubscriptπ‘ π‘š0𝑑1𝑔modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›π‘š1\displaystyle\sum_{s_{m}=0}^{t-1}\,g\left(i+s_{m}\cdot t^{m}\bmod{n},m-1\right).
Proof.

By equation (8),

g​(i,m)π‘”π‘–π‘š\displaystyle g\left(i,m\right)
=\displaystyle=βˆ‘sm=0tβˆ’1βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1(d(i,i+smβ‹…tmmodn)\displaystyle\sum_{s_{m}=0}^{t-1}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\left(d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)\vphantom{\sum_{\ell=m-1-k}^{m-2}\,s_{\ell}\cdot t^{\ell}}\right.
+βˆ‘k=0mβˆ’1d(i+smβ‹…tm+βˆ‘β„“=mβˆ’kmβˆ’1sβ„“β‹…tβ„“modn,i+smβ‹…tm+βˆ‘β„“=mβˆ’1βˆ’kmβˆ’1sβ„“β‹…tβ„“modn)),\displaystyle\left.+\sum_{k=0}^{m-1}\,d\left(i+s_{m}\cdot t^{m}+\sum_{\ell=m-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+s_{m}\cdot t^{m}+\sum_{\ell=m-1-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right)\right),
g​(i+smβ‹…tmmodn,mβˆ’1)𝑔modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›π‘š1\displaystyle g\left(i+s_{m}\cdot t^{m}\bmod{n},m-1\right)
=\displaystyle=βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1βˆ‘k=0mβˆ’1d​(i+smβ‹…tm+βˆ‘β„“=mβˆ’kmβˆ’1sβ„“β‹…tβ„“modn,i+smβ‹…tm+βˆ‘β„“=mβˆ’1βˆ’kmβˆ’1sβ„“β‹…tβ„“modn)superscriptsubscriptsubscriptπ‘ π‘š1subscriptπ‘ π‘š2…subscript𝑠00𝑑1superscriptsubscriptπ‘˜0π‘š1𝑑modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptβ„“π‘šπ‘˜π‘š1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptβ„“π‘š1π‘˜π‘š1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛\displaystyle\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\sum_{k=0}^{m-1}\,d\left(i+s_{m}\cdot t^{m}+\sum_{\ell=m-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+s_{m}\cdot t^{m}+\sum_{\ell=m-1-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right)

for sm∈{0,1,…,tβˆ’1}subscriptπ‘ π‘š01…𝑑1s_{m}\in\{0,1,\ldots,t-1\}. Furthermore,

βˆ‘sm=0tβˆ’1βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1d​(i,i+smβ‹…tmmodn)=tmβ€‹βˆ‘sm=0tβˆ’1d​(i,i+smβ‹…tmmodn).superscriptsubscriptsubscriptπ‘ π‘š0𝑑1superscriptsubscriptsubscriptπ‘ π‘š1subscriptπ‘ π‘š2…subscript𝑠00𝑑1𝑑𝑖modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›superscriptπ‘‘π‘šsuperscriptsubscriptsubscriptπ‘ π‘š0𝑑1𝑑𝑖modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›\displaystyle\sum_{s_{m}=0}^{t-1}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)=t^{m}\sum_{s_{m}=0}^{t-1}\,d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right).

∎

Lemma 7.

For all i∈{0,1,…,nβˆ’1}𝑖01…𝑛1i\in\{0,1,\ldots,n-1\} and m∈{1,2,…,hβˆ’1}π‘š12β€¦β„Ž1m\in\{1,2,\ldots,h-1\},

f​(i,m)π‘“π‘–π‘š\displaystyle f\left(i,m\right)=\displaystyle=(1+βˆ‘r=0mβˆ’1srβ€²β‹…tr)​d​(i,i+smβ€²β‹…tmmodn)1superscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿπ‘‘π‘–modulo𝑖⋅subscriptsuperscriptπ‘ β€²π‘šsuperscriptπ‘‘π‘šπ‘›\displaystyle\left(1+\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r}\right)d\left(i,i+s^{\prime}_{m}\cdot t^{m}\bmod{n}\right)
+\displaystyle+tmβ€‹βˆ‘sm=0smβ€²βˆ’1d​(i,i+smβ‹…tmmodn)superscriptπ‘‘π‘šsuperscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘š1𝑑𝑖modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›\displaystyle t^{m}\sum_{s_{m}=0}^{s^{\prime}_{m}-1}\,d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)
+\displaystyle+f​(i+smβ€²β‹…tmmodn,mβˆ’1)𝑓modulo𝑖⋅subscriptsuperscriptπ‘ β€²π‘šsuperscriptπ‘‘π‘šπ‘›π‘š1\displaystyle f\left(i+s^{\prime}_{m}\cdot t^{m}\bmod{n},m-1\right)
+\displaystyle+βˆ‘sm=0smβ€²βˆ’1g​(i+smβ‹…tmmodn,mβˆ’1).superscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘š1𝑔modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›π‘š1\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}-1}\,g\left(i+s_{m}\cdot t^{m}\bmod{n},m-1\right).
Proof.

Observe the following for all smsubscriptπ‘ π‘šs_{m}, smβˆ’1subscriptπ‘ π‘š1s_{m-1}, ……\ldots, s0∈{0,1,…,tβˆ’1}subscript𝑠001…𝑑1s_{0}\in\{0,1,\ldots,t-1\}:

  1. (i)

    If sm=smβ€²subscriptπ‘ π‘šsubscriptsuperscriptπ‘ β€²π‘šs_{m}=s^{\prime}_{m}, then βˆ‘r=0msrβ‹…trβ‰€βˆ‘r=0msrβ€²β‹…trsuperscriptsubscriptπ‘Ÿ0π‘šβ‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿsuperscriptsubscriptπ‘Ÿ0π‘šβ‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\sum_{r=0}^{m}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m}\,s^{\prime}_{r}\cdot t^{r} if and only if βˆ‘r=0mβˆ’1srβ‹…trβ‰€βˆ‘r=0mβˆ’1srβ€²β‹…trsuperscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿsuperscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\sum_{r=0}^{m-1}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r};

  2. (ii)

    If sm<smβ€²subscriptπ‘ π‘šsubscriptsuperscriptπ‘ β€²π‘šs_{m}<s^{\prime}_{m}, then βˆ‘r=0msrβ‹…tr<βˆ‘r=0msrβ€²β‹…trsuperscriptsubscriptπ‘Ÿ0π‘šβ‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿsuperscriptsubscriptπ‘Ÿ0π‘šβ‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\sum_{r=0}^{m}\,s_{r}\cdot t^{r}<\sum_{r=0}^{m}\,s^{\prime}_{r}\cdot t^{r};

  3. (iii)

    If sm>smβ€²subscriptπ‘ π‘šsubscriptsuperscriptπ‘ β€²π‘šs_{m}>s^{\prime}_{m}, then βˆ‘r=0msrβ‹…tr>βˆ‘r=0msrβ€²β‹…trsuperscriptsubscriptπ‘Ÿ0π‘šβ‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿsuperscriptsubscriptπ‘Ÿ0π‘šβ‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\sum_{r=0}^{m}\,s_{r}\cdot t^{r}>\sum_{r=0}^{m}\,s^{\prime}_{r}\cdot t^{r}.

We have

f​(i,m)π‘“π‘–π‘š\displaystyle f\left(i,m\right)
=equation (7)superscriptequation (7)\displaystyle\stackrel{{\scriptstyle\text{equation~{}(\ref{subsumlessthanorequalto})}}}{{=}}βˆ‘sm=0tβˆ’1βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1Ο‡[βˆ‘r=0msrβ‹…trβ‰€βˆ‘r=0msrβ€²β‹…tr]β‹…(d(i,i+smβ‹…tmmodn)\displaystyle\sum_{s_{m}=0}^{t-1}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\chi\left[\sum_{r=0}^{m}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m}\,s^{\prime}_{r}\cdot t^{r}\right]\cdot\left(d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)\vphantom{\sum_{\ell=m-2-k}^{m-2}\,s_{\ell}\cdot t^{\ell}\bmod{n}}\right.
+βˆ‘k=0mβˆ’1d(i+smβ‹…tm+βˆ‘β„“=mβˆ’kmβˆ’1sβ„“β‹…tβ„“modn,i+smβ‹…tm+βˆ‘β„“=mβˆ’1βˆ’kmβˆ’1sβ„“β‹…tβ„“modn))\displaystyle\left.+\sum_{k=0}^{m-1}\,d\left(i+s_{m}\cdot t^{m}+\sum_{\ell=m-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+s_{m}\cdot t^{m}+\sum_{\ell=m-1-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right)\right)
=item (iii)superscriptitem (iii)\displaystyle\stackrel{{\scriptstyle\text{item~{}(\ref{item3})}}}{{=}}βˆ‘sm=0smβ€²βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1(Ο‡[(sm=smβ€²)∧(βˆ‘r=0msrβ‹…trβ‰€βˆ‘r=0msrβ€²β‹…tr)]\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\left(\chi\left[\left(s_{m}=s^{\prime}_{m}\right)\land\left(\sum_{r=0}^{m}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m}\,s^{\prime}_{r}\cdot t^{r}\right)\right]\right.
+Ο‡[(sm<smβ€²)∧(βˆ‘r=0msrβ‹…trβ‰€βˆ‘r=0msrβ€²β‹…tr)])β‹…(d(i,i+smβ‹…tmmodn)\displaystyle\left.+\chi\left[\left(s_{m}<s^{\prime}_{m}\right)\land\left(\sum_{r=0}^{m}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m}\,s^{\prime}_{r}\cdot t^{r}\right)\right]\right)\cdot\left(d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)\vphantom{\sum_{\ell=m-2-k}^{m-2}\,s_{\ell}\cdot t^{\ell}\bmod{n}}\right.
+βˆ‘k=0mβˆ’1d(i+smβ‹…tm+βˆ‘β„“=mβˆ’kmβˆ’1sβ„“β‹…tβ„“modn,i+smβ‹…tm+βˆ‘β„“=mβˆ’1βˆ’kmβˆ’1sβ„“β‹…tβ„“modn))\displaystyle\left.+\sum_{k=0}^{m-1}\,d\left(i+s_{m}\cdot t^{m}+\sum_{\ell=m-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+s_{m}\cdot t^{m}+\sum_{\ell=m-1-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right)\right)
=item (i)superscriptitem (i)\displaystyle\stackrel{{\scriptstyle\text{item~{}(\ref{item1})}}}{{=}}βˆ‘sm=0smβ€²βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1(Ο‡[(sm=smβ€²)∧(βˆ‘r=0mβˆ’1srβ‹…trβ‰€βˆ‘r=0mβˆ’1srβ€²β‹…tr)]\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\left(\chi\left[\left(s_{m}=s^{\prime}_{m}\right)\land\left(\sum_{r=0}^{m-1}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r}\right)\right]\right.
+Ο‡[(sm<smβ€²)∧(βˆ‘r=0msrβ‹…trβ‰€βˆ‘r=0msrβ€²β‹…tr)])β‹…(d(i,i+smβ‹…tmmodn)\displaystyle\left.+\chi\left[\left(s_{m}<s^{\prime}_{m}\right)\land\left(\sum_{r=0}^{m}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m}\,s^{\prime}_{r}\cdot t^{r}\right)\right]\right)\cdot\left(d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)\vphantom{\sum_{\ell=m-2-k}^{m-2}\,s_{\ell}\cdot t^{\ell}\bmod{n}}\right.
+βˆ‘k=0mβˆ’1d(i+smβ‹…tm+βˆ‘β„“=mβˆ’kmβˆ’1sβ„“β‹…tβ„“modn,i+smβ‹…tm+βˆ‘β„“=mβˆ’1βˆ’kmβˆ’1sβ„“β‹…tβ„“modn))\displaystyle\left.+\sum_{k=0}^{m-1}\,d\left(i+s_{m}\cdot t^{m}+\sum_{\ell=m-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+s_{m}\cdot t^{m}+\sum_{\ell=m-1-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right)\right)
=item (ii)superscriptitem (ii)\displaystyle\stackrel{{\scriptstyle\text{item~{}(\ref{item2})}}}{{=}}βˆ‘sm=0smβ€²βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1(Ο‡[(sm=smβ€²)∧(βˆ‘r=0mβˆ’1srβ‹…trβ‰€βˆ‘r=0mβˆ’1srβ€²β‹…tr)]\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\left(\chi\left[\left(s_{m}=s^{\prime}_{m}\right)\land\left(\sum_{r=0}^{m-1}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r}\right)\right]\right.
+Ο‡[sm<smβ€²])β‹…(d(i,i+smβ‹…tmmodn)\displaystyle\left.+\chi\left[s_{m}<s^{\prime}_{m}\right]\vphantom{\sum_{r=0}^{m-2}\,s^{\prime}_{r}\cdot t^{r}}\right)\cdot\left(d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)\vphantom{\sum_{\ell=m-2-k}^{m-2}\,s_{\ell}\cdot t^{\ell}\bmod{n}}\right.
+βˆ‘k=0mβˆ’1d(i+smβ‹…tm+βˆ‘β„“=mβˆ’kmβˆ’1sβ„“β‹…tβ„“modn,i+smβ‹…tm+βˆ‘β„“=mβˆ’1βˆ’kmβˆ’1sβ„“β‹…tβ„“modn)).\displaystyle\left.+\sum_{k=0}^{m-1}\,d\left(i+s_{m}\cdot t^{m}+\sum_{\ell=m-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+s_{m}\cdot t^{m}+\sum_{\ell=m-1-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right)\right).

By equation (7),

f​(i+smβ€²β‹…tmmodn,mβˆ’1)𝑓modulo𝑖⋅subscriptsuperscriptπ‘ β€²π‘šsuperscriptπ‘‘π‘šπ‘›π‘š1\displaystyle f\left(i+s^{\prime}_{m}\cdot t^{m}\bmod{n},m-1\right)
=\displaystyle=βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1χ​[βˆ‘r=0mβˆ’1srβ‹…trβ‰€βˆ‘r=0mβˆ’1srβ€²β‹…tr]superscriptsubscriptsubscriptπ‘ π‘š1subscriptπ‘ π‘š2…subscript𝑠00𝑑1πœ’delimited-[]superscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿsuperscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\displaystyle\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\chi\left[\,\sum_{r=0}^{m-1}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r}\,\right]
β‹…β‹…\displaystyle\cdotβˆ‘k=0mβˆ’1d​(i+smβ€²β‹…tm+βˆ‘β„“=mβˆ’kmβˆ’1sβ„“β‹…tβ„“modn,i+smβ€²β‹…tm+βˆ‘β„“=mβˆ’1βˆ’kmβˆ’1sβ„“β‹…tβ„“modn)superscriptsubscriptπ‘˜0π‘š1𝑑modulo𝑖⋅subscriptsuperscriptπ‘ β€²π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptβ„“π‘šπ‘˜π‘š1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛modulo𝑖⋅subscriptsuperscriptπ‘ β€²π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptβ„“π‘š1π‘˜π‘š1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛\displaystyle\sum_{k=0}^{m-1}\,d\left(i+s^{\prime}_{m}\cdot t^{m}+\sum_{\ell=m-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+s^{\prime}_{m}\cdot t^{m}+\sum_{\ell=m-1-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right)
=\displaystyle=βˆ‘sm=0smβ€²βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1χ​[(sm=smβ€²)∧(βˆ‘r=0mβˆ’1srβ‹…trβ‰€βˆ‘r=0mβˆ’1srβ€²β‹…tr)]superscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘šsuperscriptsubscriptsubscriptπ‘ π‘š1subscriptπ‘ π‘š2…subscript𝑠00𝑑1πœ’delimited-[]subscriptπ‘ π‘šsubscriptsuperscriptπ‘ β€²π‘šsuperscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿsuperscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\chi\left[\,\left(s_{m}=s^{\prime}_{m}\right)\land\left(\sum_{r=0}^{m-1}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r}\right)\,\right]
β‹…β‹…\displaystyle\cdotβˆ‘k=0mβˆ’1d​(i+smβ‹…tm+βˆ‘β„“=mβˆ’kmβˆ’1sβ„“β‹…tβ„“modn,i+smβ‹…tm+βˆ‘β„“=mβˆ’1βˆ’kmβˆ’1sβ„“β‹…tβ„“modn).superscriptsubscriptπ‘˜0π‘š1𝑑modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptβ„“π‘šπ‘˜π‘š1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptβ„“π‘š1π‘˜π‘š1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛\displaystyle\sum_{k=0}^{m-1}\,d\left(i+s_{m}\cdot t^{m}+\sum_{\ell=m-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+s_{m}\cdot t^{m}+\sum_{\ell=m-1-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right).

By equation (8),

βˆ‘sm=0smβ€²βˆ’1g​(i+smβ‹…tmmodn,mβˆ’1)superscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘š1𝑔modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›π‘š1\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}-1}\,g\left(i+s_{m}\cdot t^{m}\bmod{n},m-1\right)
=\displaystyle=βˆ‘sm=0smβ€²βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1χ​[sm<smβ€²]superscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘šsuperscriptsubscriptsubscriptπ‘ π‘š1subscriptπ‘ π‘š2…subscript𝑠00𝑑1πœ’delimited-[]subscriptπ‘ π‘šsubscriptsuperscriptπ‘ β€²π‘š\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\chi\left[\,s_{m}<s^{\prime}_{m}\,\right]
β‹…β‹…\displaystyle\cdotβˆ‘k=0mβˆ’1d​(i+smβ‹…tm+βˆ‘β„“=mβˆ’kmβˆ’1sβ„“β‹…tβ„“modn,i+smβ‹…tm+βˆ‘β„“=mβˆ’1βˆ’kmβˆ’1sβ„“β‹…tβ„“modn).superscriptsubscriptπ‘˜0π‘š1𝑑modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptβ„“π‘šπ‘˜π‘š1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptβ„“π‘š1π‘˜π‘š1β‹…subscript𝑠ℓsuperscript𝑑ℓ𝑛\displaystyle\sum_{k=0}^{m-1}\,d\left(i+s_{m}\cdot t^{m}+\sum_{\ell=m-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n},i+s_{m}\cdot t^{m}+\sum_{\ell=m-1-k}^{m-1}\,s_{\ell}\cdot t^{\ell}\bmod{n}\right).

Because each number in {0,1,…,βˆ‘r=0mβˆ’1srβ€²β‹…tr}01…superscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\{0,1,\ldots,\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r}\} can be written uniquely as βˆ‘r=0mβˆ’1srβ‹…trsuperscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿ\sum_{r=0}^{m-1}\,s_{r}\cdot t^{r}, where smβˆ’1subscriptπ‘ π‘š1s_{m-1}, smβˆ’2subscriptπ‘ π‘š2s_{m-2}, ……\ldots, s0∈{0,1,…,tβˆ’1}subscript𝑠001…𝑑1s_{0}\in\{0,1,\ldots,t-1\},

βˆ‘sm=0smβ€²βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1χ​[(sm=smβ€²)∧(βˆ‘r=0mβˆ’1srβ‹…trβ‰€βˆ‘r=0mβˆ’1srβ€²β‹…tr)]superscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘šsuperscriptsubscriptsubscriptπ‘ π‘š1subscriptπ‘ π‘š2…subscript𝑠00𝑑1πœ’delimited-[]subscriptπ‘ π‘šsubscriptsuperscriptπ‘ β€²π‘šsuperscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptπ‘ π‘Ÿsuperscriptπ‘‘π‘Ÿsuperscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\chi\left[\,\left(s_{m}=s^{\prime}_{m}\right)\land\left(\sum_{r=0}^{m-1}\,s_{r}\cdot t^{r}\leq\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r}\right)\,\right]
β‹…β‹…\displaystyle\cdotd​(i,i+smβ‹…tmmodn)𝑑𝑖modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›\displaystyle d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)
=\displaystyle=βˆ‘sm=0smβ€²(1+βˆ‘r=0mβˆ’1srβ€²β‹…tr)⋅χ​[sm=smβ€²]β‹…d​(i,i+smβ‹…tmmodn)superscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘šβ‹…β‹…1superscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿπœ’delimited-[]subscriptπ‘ π‘šsubscriptsuperscriptπ‘ β€²π‘šπ‘‘π‘–modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}}\,\left(1+\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r}\right)\cdot\chi\left[\,s_{m}=s^{\prime}_{m}\,\right]\cdot d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)
=\displaystyle=(1+βˆ‘r=0mβˆ’1srβ€²β‹…tr)​d​(i,i+smβ€²β‹…tmmodn).1superscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿπ‘‘π‘–modulo𝑖⋅subscriptsuperscriptπ‘ β€²π‘šsuperscriptπ‘‘π‘šπ‘›\displaystyle\left(1+\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r}\right)d\left(i,i+s^{\prime}_{m}\cdot t^{m}\bmod{n}\right).

Finally,

βˆ‘sm=0smβ€²βˆ‘smβˆ’1,smβˆ’2,…,s0=0tβˆ’1χ​[sm<smβ€²]β‹…d​(i,i+smβ‹…tmmodn)superscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘šsuperscriptsubscriptsubscriptπ‘ π‘š1subscriptπ‘ π‘š2…subscript𝑠00𝑑1β‹…πœ’delimited-[]subscriptπ‘ π‘šsubscriptsuperscriptπ‘ β€²π‘šπ‘‘π‘–modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›\displaystyle\sum_{s_{m}=0}^{s^{\prime}_{m}}\,\sum_{s_{m-1},s_{m-2},\ldots,s_{0}=0}^{t-1}\,\chi\left[\,s_{m}<s^{\prime}_{m}\,\right]\cdot d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right)(14)
=\displaystyle=tmβ€‹βˆ‘sm=0smβ€²βˆ’1d​(i,i+smβ‹…tmmodn).superscriptπ‘‘π‘šsuperscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘š1𝑑𝑖modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›\displaystyle t^{m}\sum_{s_{m}=0}^{s^{\prime}_{m}-1}\,d\left(i,i+s_{m}\cdot t^{m}\bmod{n}\right).

Equations (2)–(14) complete the proof. ∎

1:  tβ†βŒˆn1/hβŒ‰β†π‘‘superscript𝑛1β„Žt\leftarrow\lceil n^{1/h}\rceil;
2:  Find the t𝑑t-ary representation of nβˆ’1𝑛1n-1, denoted (shβˆ’1β€²,shβˆ’2β€²,…,s0β€²)∈{0,1,…,tβˆ’1}hsubscriptsuperscriptπ‘ β€²β„Ž1subscriptsuperscriptπ‘ β€²β„Ž2…subscriptsuperscript𝑠′0superscript01…𝑑1β„Ž(s^{\prime}_{h-1},s^{\prime}_{h-2},\ldots,s^{\prime}_{0})\in\{0,1,\ldots,t-1\}^{h};
3:  for i∈{0,1,…,nβˆ’1}𝑖01…𝑛1i\in\{0,1,\ldots,n-1\} do
4:     f​[i]​[0]β†βˆ‘s0=0s0β€²d​(i,i+s0modn)←𝑓delimited-[]𝑖delimited-[]0superscriptsubscriptsubscript𝑠00subscriptsuperscript𝑠′0𝑑𝑖modulo𝑖subscript𝑠0𝑛f[i][0]\leftarrow\sum_{s_{0}=0}^{s^{\prime}_{0}}\,d(i,i+s_{0}\bmod{n});
5:     g​[i]​[0]β†βˆ‘s0=0tβˆ’1d​(i,i+s0modn)←𝑔delimited-[]𝑖delimited-[]0superscriptsubscriptsubscript𝑠00𝑑1𝑑𝑖modulo𝑖subscript𝑠0𝑛g[i][0]\leftarrow\sum_{s_{0}=0}^{t-1}\,d(i,i+s_{0}\bmod{n});
6:  end for
7:  for m=1π‘š1m=1 up to hβˆ’1β„Ž1h-1 do
8:     for i∈{0,1,…,nβˆ’1}𝑖01…𝑛1i\in\{0,1,\ldots,n-1\} do
9:        f​[i]​[m]←(1+βˆ‘r=0mβˆ’1srβ€²β‹…tr)​d​(i,i+smβ€²β‹…tmmodn)←𝑓delimited-[]𝑖delimited-[]π‘š1superscriptsubscriptπ‘Ÿ0π‘š1β‹…subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿπ‘‘π‘–modulo𝑖⋅subscriptsuperscriptπ‘ β€²π‘šsuperscriptπ‘‘π‘šπ‘›f[i][m]\leftarrow(1+\sum_{r=0}^{m-1}\,s^{\prime}_{r}\cdot t^{r})\,d(i,i+s^{\prime}_{m}\cdot t^{m}\bmod{n});
10:        f​[i]​[m]←f​[i]​[m]+tmβ€‹βˆ‘sm=0smβ€²βˆ’1d​(i,i+smβ‹…tmmodn)←𝑓delimited-[]𝑖delimited-[]π‘šπ‘“delimited-[]𝑖delimited-[]π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘š1𝑑𝑖modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›f[i][m]\leftarrow f[i][m]+t^{m}\sum_{s_{m}=0}^{s^{\prime}_{m}-1}\,d(i,i+s_{m}\cdot t^{m}\bmod{n});
11:        f​[i]​[m]←f​[i]​[m]+f​[i+smβ€²β‹…tmmodn]​[mβˆ’1]←𝑓delimited-[]𝑖delimited-[]π‘šπ‘“delimited-[]𝑖delimited-[]π‘šπ‘“delimited-[]modulo𝑖⋅subscriptsuperscriptπ‘ β€²π‘šsuperscriptπ‘‘π‘šπ‘›delimited-[]π‘š1f[i][m]\leftarrow f[i][m]+f[i+s^{\prime}_{m}\cdot t^{m}\bmod{n}][m-1];
12:        f​[i]​[m]←f​[i]​[m]+βˆ‘sm=0smβ€²βˆ’1g​[i+smβ‹…tmmodn]​[mβˆ’1]←𝑓delimited-[]𝑖delimited-[]π‘šπ‘“delimited-[]𝑖delimited-[]π‘šsuperscriptsubscriptsubscriptπ‘ π‘š0subscriptsuperscriptπ‘ β€²π‘š1𝑔delimited-[]modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›delimited-[]π‘š1f[i][m]\leftarrow f[i][m]+\sum_{s_{m}=0}^{s^{\prime}_{m}-1}\,g[i+s_{m}\cdot t^{m}\bmod{n}][m-1];
13:        g​[i]​[m]←tmβ€‹βˆ‘sm=0tβˆ’1d​(i,i+smβ‹…tmmodn)←𝑔delimited-[]𝑖delimited-[]π‘šsuperscriptπ‘‘π‘šsuperscriptsubscriptsubscriptπ‘ π‘š0𝑑1𝑑𝑖modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›g[i][m]\leftarrow t^{m}\sum_{s_{m}=0}^{t-1}\,d(i,i+s_{m}\cdot t^{m}\bmod{n});
14:        g​[i]​[m]←g​[i]​[m]+βˆ‘sm=0tβˆ’1g​[i+smβ‹…tmmodn]​[mβˆ’1]←𝑔delimited-[]𝑖delimited-[]π‘šπ‘”delimited-[]𝑖delimited-[]π‘šsuperscriptsubscriptsubscriptπ‘ π‘š0𝑑1𝑔delimited-[]modulo𝑖⋅subscriptπ‘ π‘šsuperscriptπ‘‘π‘šπ‘›delimited-[]π‘š1g[i][m]\leftarrow g[i][m]+\sum_{s_{m}=0}^{t-1}\,g[i+s_{m}\cdot t^{m}\bmod{n}][m-1];
15:     end for
16:  end for
17:  Output argmini=0nβˆ’1f​[i]​[hβˆ’1]superscriptsubscriptargmin𝑖0𝑛1𝑓delimited-[]𝑖delimited-[]β„Ž1\mathop{\mathrm{argmin}}_{i=0}^{n-1}\,f[i][h-1], breaking ties arbitrarily;
Figure 1: Algorithm find-median with input a metric space ({0,1,…,nβˆ’1},d)01…𝑛1𝑑(\{0,1,\ldots,n-1\},d) and hβˆˆβ„€+βˆ–{1}β„Žsuperscriptβ„€1h\in\mathbb{Z}^{+}\setminus\{1\}.
Lemma 8.

Algorithm find-median in Fig. 1 is (2​h)2β„Ž(2h)-approximate for metric 111-median.

Proof.

By equations (9)–(10), lines 4–5 of find-median compute f​(i,0)𝑓𝑖0f(i,0) and g​(i,0)𝑔𝑖0g(i,0). Then, by Lemmas 6–7, f​(i,m)π‘“π‘–π‘šf(i,m) and g​(i,m)π‘”π‘–π‘šg(i,m) can be found by dynamic programming as in lines 9–14. So line 17 outputs argmini=0nβˆ’1f​(i,hβˆ’1)superscriptsubscriptargmin𝑖0𝑛1π‘“π‘–β„Ž1\mathop{\mathrm{argmin}}_{i=0}^{n-1}\,f(i,h-1), which equals

argmini=0nβˆ’1βˆ‘j=0nβˆ’1d~​(i,i+jmodn)superscriptsubscriptargmin𝑖0𝑛1superscriptsubscript𝑗0𝑛1~𝑑𝑖modulo𝑖𝑗𝑛\mathop{\mathrm{argmin}}_{i=0}^{n-1}\,\sum_{j=0}^{n-1}\,\tilde{d}\left(i,i+j\bmod{n}\right)

by Lemma 5. Now Lemma 4 gives the approximation ratio of 2​h2β„Ž2h. ∎

We now state our main theorem.

Theorem 9.

Metric 111-median has a deterministic O​(h​n1+1/h)π‘‚β„Žsuperscript𝑛11β„ŽO(hn^{1+1/h})-time (2​h)2β„Ž(2h)-approximation nonadaptive algorithm for each hβˆˆβ„€+βˆ–{1}β„Žsuperscriptβ„€1h\in\mathbb{Z}^{+}\setminus\{1\}.

Proof.

Clearly, find-median is deterministic and nonadaptive. Furthermore, it is (2​h)2β„Ž(2h)-approximate for metric 111-median by Lemma 8. As si′≀tβˆ’1subscriptsuperscript𝑠′𝑖𝑑1s^{\prime}_{i}\leq t-1 for all i∈{0,1,…,hβˆ’1}𝑖01β€¦β„Ž1i\in\{0,1,\ldots,h-1\}, the loop in lines 3–6 of find-median takes O​(n​t)𝑂𝑛𝑑O(nt) time. By precomputing tisuperscript𝑑𝑖t^{i} and βˆ‘r=0isrβ€²β‹…trsuperscriptsubscriptπ‘Ÿ0𝑖⋅subscriptsuperscriptπ‘ β€²π‘Ÿsuperscriptπ‘‘π‘Ÿ\sum_{r=0}^{i}\,s^{\prime}_{r}\cdot t^{r} for all i∈{0,1,…,hβˆ’1}𝑖01β€¦β„Ž1i\in\{0,1,\ldots,h-1\}, each iteration of the loop in lines 8–15 takes O​(t)𝑂𝑑O(t) time. ∎

References

  • [1] M. R. Ackermann, J. BlΓΆmer, and C. Sohler. Clustering for metric and nonmetric distance measures. ACM Transactions on Algorithms, 6(4), 2010. Article 59.
  • [2] C.-L. Chang. Deterministic sublinear-time approximations for metric 111-median selection. Information Processing Letters, 113(8):288–292, 2013.
  • [3] C.-L. Chang. A lower bound for metric 111-median selection. Technical Report arXiv: 1401.2195, 2014.
  • [4] S. Guha, A. Meyerson, N. Mishra, R. Motwani, and L. O’Callaghan. Clustering data streams: Theory and practice. IEEE Transactions on Knowledge and Data Engineering, 15(3):515–528, 2003.
  • [5] P. Indyk. Sublinear time algorithms for metric space problems. In Proceedings of the 31st Annual ACM Symposium on Theory of Computing, pages 428–434, 1999.
  • [6] P. Indyk. High-dimensional computational geometry. PhD thesis, Stanford University, 2000.
  • [7] A. Kumar, Y. Sabharwal, and S. Sen. Linear-time approximation schemes for clustering problems in any dimensions. Journal of the ACM, 57(2):5, 2010.
  • [8] B.-Y. Wu. On approximating metric 111-median in sublinear time. Information Processing Letters, 114(4):163–166, 2014.