# Quantum versus Classical Online Algorithms with Advice and Logarithmic Space

In this paper, we consider online algorithms. Typically the model is investigated with respect to competitive ratio. We consider algorithms with restricted memory (space) and explore their power. We focus on quantum and classical online algorithms. We show that there are problems that can be better solved by quantum algorithms than classical ones in a case of logarithmic memory. Additionally, we show that quantum algorithm has an advantage, even if deterministic algorithm gets advice bits. We propose "Black Hats Method". This method allows us to construct problems that can be effectively solved by quantum algorithms. At the same time, these problems are hard for classical algorithms. The separation between probabilistic and deterministic algorithms can be shown with a similar method.

• 20 publications
• 5 publications
• 4 publications
• 1 publication
09/25/2017

### Quantum Online Algorithms with Respect to Space Complexity

Online algorithm is a well-known computational model. We introduce quant...
02/13/2018

### Quantum Online Streaming Algorithms with Constant Number of Advice Bits

Online algorithms are known model that is investigated with respect to a...
05/06/2021

### Quantum Logarithmic Space and Post-selection

Post-selection, the power of discarding all runs of a computation in whi...
05/06/2020

### Towards quantum advantage for topological data analysis

A particularly promising line of quantum machine leaning (QML) algorithm...
11/10/2021

### Exponential separations between learning with and without quantum memory

We study the power of quantum memory for learning properties of quantum ...
02/01/2021

Building on the quantum ensemble based classifier algorithm of Schuld an...
06/08/2020

### Quantum Logspace Algorithm for Powering Matrices with Bounded Norm

We give a quantum logspace algorithm for powering contraction matrices, ...

## 1 Introduction

Online algorithms are well-known as a computational model for solving optimization problems. The defining property of this model is that algorithm reads an input piece by piece and should return output variables after some of input variables immediately, even if the answer depends on whole input. An online algorithm should return an output for minimizing an objective function. There are different methods to define the effectiveness of algorithms [BIL09, DLO05], but the most standard is the competitive ratio [KMRS86]. It is a ratio between output’s price for a solution of an online algorithm and a solution of an optimal offline algorithm.

Typically, online algorithms have unlimited computational power and the main restriction is lack of knowledge on future input variables. And there are many problems that can be formulated in this terms. At the same time it is quite interesting to solve online minimization problem in a case of big input stream. We consider a big stream such that it cannot be stored in a memory. In that case we can discuss online algorithms with restricted memory. In the paper we consider streaming algorithms as online algorithm and they use only bits of memory, for given integer . This classical model were considered in [BK09, GK15, BLM15, KKM17]. Automata for online minimization problems were considered in [KK17a]. And we interested in investigation of a new model of online algorithms, quantum online algorithms that use a power of quantum computing for solving online minimization problem. This model was introduced in [KKM17]. And especially quantum streaming algorithms as quantum online algorithms. It is already known that quantum online algorithms can be better than classical ones in a case of sublogarithmic memory [KKM17]. At the same time it is interesting to consider logarithmic space (memory). In this case, only quantum online algorithms with repeated test were considered in [Yua09]. In this papaer we focus on quantum online algorithms that reads input only once.

We are also interested in advice complexity measure [Kom16, BFK17]. In this model online algorithm gets some bits of advice about an input. Trusted Adviser sending these bits knows the whole input and has an unlimited computational power. The question is “how many advice bits are enough to reduce competitive ratio or to make the online algorithm as the same effective as the offline algorithm?”. This question has different interpretations. One of them is “How many information an algorithm should know about a future for solving a problem effectively?”. Another one is “If we have an expensive channel which can be used for pre-processed information about the future, then how many bits we should send by this channel to solve a problem effectively?”. Researchers pay attention to deterministic and probabilistic or randomized online algorithms with advice [Hro05, Kom16]. It is interesting to compare power of quantum online algorithms and classical ones in a case of using streaming algorithms with logarithmic space (memory). This question was not investigated before.

In the paper we present “Black Hats Method” for constructing hard online minimization problems. Using this method we construct problems for separation between power of quantum and classical algorithms. Let we allow algorithms to use only bits of memory.

• BHR problem has a quantum online algorithm with better competitive ratio than any classical (randomized or deterministic) online algorithms. Additionally, we show that if deterministic online algorithm gets an advice then quantum online algorithms still have better competitive ratio. The problem is based on function from [SS05].

• BHE problem has quantum and randomized online algorithms with better competitive ratio than any deterministic online algorithm. Additionally, we show that if deterministic online algorithm gets an advice then quantum or randomized online algorithms still shows better competitive ratio. The problem is based on Equality function and results from [AKV10, AN09, AF98, Fre79].

For both problems, quantum online algorithms with bits of memory have better competitive ratio than any online deterministic algorithm with unlimited computational power.

Online algorithms with restricted memory are similar to streaming algorithms [LG06, GKK07], Branching programs [Weg00] and automata [AY12, AY15]. Researchers also compare classical and quantum cases for these models [AGK05], [AGKY14, AGKY16, Gai15, SS05, KK17b, AY12, AY15, LG06, AAKK17, IKPY17].

The paper is organized in the following way. We present definitions in Section 2. Black Hats Method is described in Section 3. A discussion on Quantum and Randomized vs Deterministic online algorithms is in the first part of Section 4. The second part of the Section contains results on Quantum vs Classical Online Algorithms.

## 2 Preliminaries

Firstly, let us define the online optimization problem. All following definitions we give with respect to [Kom16, KKM17]. Also the definitions are agreed with [Yua09]. An online minimization problem consists of a set of inputs and a cost function. Every input is a sequence of requests . Furthermore, a set of feasible outputs (or solutions) is associated with every ; every output is a sequence of answers . The cost function assigns a positive real value to every input and any feasible output . For every input , we call any feasible output for that has the smallest possible cost (i. e., that minimizes the cost function) an optimal solution for .

Let us define an online algorithm for this problem as an algorithm which gets requests from one by one and should return answers from immediately, even if optimal solution can depend on future requests. A deterministic online algorithm computes the output sequence such that is computed from , . This setting can also be regarded as a request-answer game: an adversary generates requests, and an online algorithm has to serve them one at a time [Alb96].

We use competitive ratio as a main measure of quality of the online algorithm. It is the ratio of costs of the algorithm’s solution and a solution of an optimal offline algorithm, in the worst case.

We say that online deterministic algorithm is -competitive if there exists a non-negative constant such that, for every input , we have: where is an optimal offline algorithm for the problem. We also call the competitive ratio of . If , then is called strictly -competitive; is optimal if it is strictly -competitive.

Let us define an Online Algorithm with Advice. We can say that advice is some information about future input. An online algorithm with advice computes the output sequence such that is computed from , where is the message from Adviser, who knows the whole input. is -competitive with advice complexity if there exists a non-negative constant such that, for every and for any input , there exists some such that and , where is length of .

Next, let us define a randomized online algorithm. A randomized online algorithm computes the output sequence such that is computed from , where is the content of a random tape, i. e., an infinite binary sequence, where every bit is chosen uniformly at random and independently of all the others. By

we denote the random variable expressing the cost of the solution computed by

on . is -competitive in expectation if there exists a non-negative constant such that, for every , .

We will consider online algorithms with restricted memory. We use streaming algorithms for online minimization problem as online algorithms with restricted memory. You can read more about streaming algorithms in literature [M05, AR13]. Shortly, these are algorithms that use small size of memory and read input variables one by one.

Suppose is deterministic online streaming algorithm with bits of memory that process input . Then we can describe a state of memory of before reading input variable

by vector

. The algorithm computes output such that depends on and ; depends on and . Randomized online streaming algorithm and deterministic online streaming algorithm with advise have similar definition, but with respect to definitions of corresponding models of online algorithms.

Now we are ready to define a quantum online algorithm. You can read more about quantum computation in [AY15]. A quantum online algorithm computes the output sequence such that is computed from

. The algorithm can measure qubits several times during computation. By

we denote the cost of the solution computed by on . Note that quantum computation is probabilistic process. is -competitive in expectation if there exists a non-negative constant such that, for every , where is an optimal offline algorithm for the problem.

Let us consider a quantum online streaming algorithm that use qubits of memory. For a given , a quantum online algorithm with qubits is defined on input and outputs variables . The algorithm is a 3-tuple where are (left) unitary matrices representing the transitions. Here is applied on the -th step. is a initial vector from -dimensional Hilbert space over the field of complex numbers. where is function that converts result of measurement to output variable .

For any given input , the computation of on can be traced by a -dimensional vector from Hilbert space over the field of complex numbers. The initial one is . In each step , , the input variable is tested and then the corresponding unitary operator is applied: where represents the state of the system after the -th step, for . The algorithm can measure one of qubits or more; or it can skip measurement. Suppose that is in the state before measurement and measures the -th qubit. Let states with numbers correspond to value of the -th qubit, and states with numbers correspond to value of the -th qubit. The result of measurement of -th qubit is

with probability

and with probability . The algorithm can measure qubits on any step after unitary transformation. If measured qubits, then as a result it gets number . In some step , with respect to definition of the problem, the algorithm returns .

There are OBDD models and automata models that are good abstractions for streaming algorithms. You can read more about classical and quantum OBDDs in [Weg00, SS05, AGK01, AGK05, AGKY14, AGKY16, KK17b]. Formal definition of OBDDs and automata are given in Appendix 0.A. Following relations between automata, id-OBDDs (OBDD that reads input variables in natural order) and streaming algorithms are folklore:

###### Lemma 1

Following claims are right: If a quantum (probabilistic) id-OBDD of width computes Boolean function , then there is a quantum (randomized) streaming algorithm computing that uses qubits (bits). If a quantum (probabilistic) automaton with size recognizes a language , then there is a quantum (randomized) streaming algorithm recognizing that uses qubits (bits). If any deterministic (probabilistic) id-OBDD computing a Boolean function has width at least , then any deterministic (randomized) streaming algorithm computing uses at least bits. If any deterministic (probabilistic) automaton recognizing a language has width at least , then any deterministic (randomized) streaming algorithm recognizing uses at least bits.

## 3 Black Hats Method for Constructing Online Minimization Problems

Let us define a method which allows to construct hard online minimization problems. We call it “Black Hats Method”. It is generalization of problem from [KKM17].

In the paper we discuss Boolean function , but in fact we consider a family of Boolean functions , for . We use notation for if length of is and it is clear from the context.

Suppose we have Boolean function and positive integers , where mod . Then online minimization problem is following. We have guardians and prisoners. They stay one by one in a line like , where is a guardian, is a prisoner. Prisoner has input of length and computes function . If result is , then a prisoner paints his hat black, otherwise he paints it white. Each guardian wants to know a parity for number of following black hats. We separate sequential guardians into blocks. The cost of a block is if all guardians of the block are right, and otherwise. We want to minimize the cost of output.

Let us define the problem formally:

###### Definition 1 (Black Hats Method)

We have a Boolean functions . Then online minimization problem , for positive integers , where mod , is following: Suppose we have input of length and positive integers , where . Let is always such that , where , for . Let be an output and be an output bits corresponding to input variables with value (an other words, output variables for guardians). Output corresponds to input variable (with value ), where . Let . We separate all output variables to blocks of length . The cost of -th block is . Where , if for ; and otherwise. Cost of the whole output is . We also consider two specific cases of the problem: and

We have following complexity results for problem:

###### Theorem 3.1

Let we allow all algorithms to use at most bits of memory. Let Boolean function be such that there are no deterministic streaming algorithms that compute . Then for any deterministic online streaming algorithm solving , there is an input such that for any . And there is no -competitive deterministic online streaming algorithm, where . (See Appendix 0.B)

###### Theorem 3.2

Let we allow all algorithms to use at most bits of memory. Let Boolean function be such that there are no randomized streaming algorithms that compute . Suppose that a randomized online streaming algorithm solves . Then there is an input such that for any and we have: . And there are no randomized online streaming algorithm that -competitive, where . (See Appendix 0.C)

We also have a bound for competitive ratio in the case of unlimited computational power for a deterministic online algorithm.

###### Theorem 3.3

There is no deterministic online algorithm computing that is -competitive, for . Particularly, there is no algorithm for that is -competitive, for .(See Appendix 0.D)

###### Theorem 3.4

Let Boolean function such that there is the randomized streaming algorithm that computes with bounded error using bits of memory, where . Then there is probabilistic online streaming algorithm using space at most bits solving such that for any input and we have

###### Proof

We use following algorithm :

Step 1 guesses the first bit of the output with equal probabilities. The algorithm stores current result in a bit . So, or with probability . Then returns .

Step 2 After that the algorithm reads and computes , where is the result of computation for on the input . Then the algorithm returns .

Step The algorithm reads , computes and returns .

Let us compute a cost of the output for this algorithm. Let us consider a new cost function . For this function, a “right” block costs and a “wrong” block costs . In that case . Therefore in following proof we can consider only function.

Firstly, let us compute the probability that block is a “right” block (or costs ). Let . So, if -th block is “right”, then all prisoners inside block return right answers and guess of the first guardian is right. A probability of this event is .

Let . If -th block is “right”, then two conditions should be true: (i) All prisoners inside block should return right answers. (ii) A number of preceding guardians that return wrong answer plus the preceding prisoner should be even. A probability of the first condition is . Let us compute a probability of the second condition.

Let be the number of errors before -th guardian. It is a number of errors for previous prisoners plus if the guess of the first guardian is wrong. Let be a probability that is even. Therefore is a probability that

is odd. If

-th prisoner has an error then should be odd; and should be even otherwise. Therefore, . Note that with probability the guess of the first guardian is right, therefore . So The probability of the event is: So expected cost is And final formula as in the claim of the theorem: .

The detailed computation is presented in Appendix 0.E.

Let us discuss quantum counterpart of this result.

###### Theorem 3.5

Let Boolean function such that there is a quantum streaming algorithm that computes with bounded error using bits of memory, where . Then there is a quantum online streaming algorithm using space at most qubits solving such that for any input and we have

. If then (See Appendix 0.F)

Note that for some functions quantum algorithms do not use such big memory. For example, in [KKM17] we presented problem that requires only one qubit.

Advice complexity. Let us consider the model with advice. The problem has following properties with respect to online algorithms with advice.

###### Theorem 3.6

Let Boolean function be such that there are no deterministic streaming algorithms that compute using space less than bits. Then for any deterministic online streaming algorithm using space less than bits, advice bits and solving , there is an input such that , for . And competitive ratio of the algorithm is .(See Appendix 0.G)

Sometimes advice bits do not help us at all. We present example of such result in the next corollary.

###### Corollary 1

Let Boolean function such that there are no deterministic streaming algorithms that computes using space less than bits. Then for any deterministic online streaming algorithm using space less than bits, advice bits and solving , where , there is an input such that . And competitive ratio of the algorithm is .

## 4 Application

Quantum and Probabilistic vs Deterministic Algorithms. In this section we will use results for OBDDs. Let us apply the Black Hats Method from Section 3 to Boolean function from [AKV10]. Boolean function is such that , if , and otherwise. It is known from [AKV10, Fre79, AGK05] that there is a quantum and randomized OBDDs that compute using linear width.

###### Lemma 2 ([Akv10, Fre79, Agk+05])

For arbitrary the function can be computed with one-sided error by a quantum OBDD of width and randomized OBDD of width , where is the length of the input. There is no deterministic OBDD of width computing .

The next corollary follows from these lemmas and Lemma 1.

###### Corollary 2

Following claims are right: (i) there are quantum and randomized streaming algorithms that computes using qubits with one-sided error ; (ii) there is no deterministic streaming algorithm that computes using bits.

Let us consider problem. Recall that is black hat problem for guardians, blocks of guardians, cost for right answer of a block and cost for wrong answer of a block.

Let us discuss properties of problem:

###### Theorem 4.1

Following claims are right for and , , mod , .

1. There are quantum and randomized online streaming algorithms and that use qubits (bits) and solves such that and are expected competitive for .

2. There is no deterministic online streaming algorithm using bits of memory and solving that is -competitive for .

3. There is no deterministic online steaming algorithm using bits of memory, advice bits and solving that is -competitive for , .

4. There is no deterministic online streaming algorithm using bits of memory, advice bits and solving that is -competitive for .

5. There is no deterministic online algorithm with unlimited computational power solving that is -competitive, for .

###### Proof

The claims follows from Corollary 2 and following properties of Black Hats Method: Theorems 3.4,3.5, 3.1, 3.2, 3.6 and Corollary 1.

This theorem gives us following important results:

1. Quantum and randomized online streaming algorithms with logarithmic space for have better competitive ratio than (i) Any deterministic online streaming algorithm with polylogarithmic space and polylogarithmic number of advice bits. (ii) Any deterministic online algorithm without restriction on memory.

2. Increasing advice bits for deterministic online streaming algorithm for gives us better competitive ratio in a case of polylogarithmic space, for . But competitive ratio still worse than for quantum and randomized online streaming algorithms.

Quantum vs Classical Algorithms. In this section as in the previous one we use results for OBDDs. Let us apply the Black Hats Method from Section 3 to Boolean function from [SS05]:

Let be the standard basis of . Let and denote the subspaces spanned by the first and last of these basis vectors. Let . The input for the function consists of boolean variables , which are interpreted as universal - codes for three unitary -matrices A, B, C, where . The function takes the value if the Euclidean distance between and is at most . Otherwise the function is undefined.

For the function following results are known.

###### Lemma 3 ([Ss05])

Let . The function with an input size of has QOBDDs with error at most and width . Let . Each randomized OBDD with bounded error for the function on variables has size .

The next corollary follows from the previous lemma and Lemma 1.

###### Corollary 3

Following claims are right: (i) there is a quantum streaming algorithm that computes using qubits with bounded error ; (ii) there is no probabilistic streaming algorithm that computes using bits with bounded error.

Let us consider problem. Recall that is black hat problem for guardians, blocks of guardians, cost for right answer of a block and cost for wrong answer of a block.

Let us discuss properties of problem:

###### Theorem 4.2

Following claims are right for , , , mod , .

1. There is quantum online streaming algorithm using qubits that solving that is expected competitive, for

2. There is no deterministic online streaming algorithm using bits of memory and solving that is -competitive, for .

3. There is no randomized online streaming algorithm using bits of memory and solving that is -competitive, for .

4. There is no deterministic online streaming algorithm using bits of memory, advice bits and solving that is -competitive, for , where .

5. There is no deterministic online streaming algorithm using bits of memory, advice bits and solving that is -competitive, for .

6. There is no deterministic online algorithm with unlimited computational power solving that is -competitive, for .

###### Proof

The claims follows from Corollary 3 and properties of Black Hats Method: Theorems 3.5, 3.1, 3.2, 3.6 and Corollary 1.

This theorem gives us following important results:

1.Quantum online streaming algorithm with logarithmic space for have better competitive ratio than: (i) any randomized online streaming algorithm with polylogarithmic space; and any deterministic online streaming algorithm with polylogarithmic space even if it use polylogarithmic number of advice bits. (ii) any deterministic online algorithm without restriction on memory.

2. Increasing advice bits for deterministic and randomized algorithms for gives us better competitive ratio in case of polylogarithmic space, for . But competitive ratio still worse than for quantum online streaming algorithm.

Acknowledgements. This work was supported by ERC Advanced Grant MQC. The work is performed according to the Russian Government Program of Competitive Growth of Kazan Federal University. We thank Andris Ambainis, Alexanders Belovs and Abuzer Yakarilmaz for helpful discussions.

## References

• [AAKK17] F. Ablayev, A. Ambainis, K. Khadiev, and A. Khadieva. Lower bounds and hierarchies for quantum automata communication protocols and quantum ordered binary decision diagrams with repeated test. 2017. arXiv:1703.05015.
• [AF98] A. Ambainis and R. Freivalds. 1-way quantum finite automata: strengths, weaknesses and generalizations. In FOCS’98, pages 332–341, 1998.
• [AGK01] F. Ablayev, A. Gainutdinova, and M. Karpinski. On computational power of quantum branching programs. In FCT, volume 2138 of LNCS, pages 59–70. Springer, 2001.
• [AGK05] F. Ablayev, A. Gainutdinova, M. Karpinski, C. Moore, and C. Pollett. On the computational power of probabilistic and quantum branching program. Information and Computation, 203(2):145–162, 2005.
• [AGKY14] Farid Ablayev, Aida Gainutdinova, Kamil Khadiev, and Abuzer Yakaryılmaz. Very narrow quantum obdds and width hierarchies for classical obdds. In DCFS, volume 8614 of LNCS, pages 53–64. Springer, 2014.
• [AGKY16] F. Ablayev, A. Gainutdinova, K. Khadiev, and A. Yakaryılmaz. Very narrow quantum obdds and width hierarchies for classical obdds. Lobachevskii Journal of Mathematics, 37(6):670–682, 2016.
• [AKV10] F. Ablayev, A. Khasianov, and A. Vasiliev. On complexity of quantum branching programs computing equality-like boolean functions. ECCC, 2010.
• [Alb96] Susanne Albers. BRICS, Mini-Course on Competitive Online Algorithms. Aarhus University, 1996.
• [AN09] Andris Ambainis and Nikolajs Nahimovs. Improved constructions of quantum automata. Theoretical Computer Science, 410(20):1916–1922, 2009.
• [AR13] Charu C Aggarwal and Chandan K Reddy. Data clustering: algorithms and applications. CRC press, 2013.
• [AY12] A. Ambainis and A. Yakaryılmaz. Superiority of exact quantum automata for promise problems. Information Processing Letters, 112(7):289–291, 2012.
• [AY15] Andris Ambainis and Abuzer Yakaryılmaz. Automata and quantum computing. Technical Report 1507.01988, arXiv, 2015.
• [BFK17] J. Boyar, L.M Favrholdt, C. Kudahl, K.S Larsen, and J.W Mikkelsen. Online algorithms with advice: A survey. ACM Computing Surveys (CSUR), 50(2):19, 2017.
• [BIL09] Joan Boyar, Sandy Irani, and Kim S Larsen. A comparison of performance measures for online algorithms. In Workshop on Algorithms and Data Structures, pages 119–130. Springer, 2009.
• [BK09] Luca Becchetti and Elias Koutsoupias. Competitive analysis of aggregate max in windowed streaming. In Automata, Languages and Programming: ICALP 2009 Proceedings, Part I, pages 156–170. Springer, 2009.
• [BLM15] Joan Boyar, Kim S Larsen, and Abyayananda Maiti. The frequent items problem in online streaming under various performance measures. International Journal of Foundations of Computer Science, 26(4):413–439, 2015.
• [DLO05] Reza Dorrigiv and Alejandro López-Ortiz. A survey of performance measures for on-line algorithms. SIGACT News, 36(3):67–81, 2005.
• [Fre79] Rūsiņš Freivalds. Fast probabilistic algorithms. In Mathematical Foundations of Computer Science 1979, volume 74 of LNCS, pages 57–69, 1979.
• [Gai15] A. Gainutdinova. Comparative complexity of quantum and classical obdds for total and partial functions. Russian Mathematics, 59(11):26–35, 2015.
• [GK15] Yiannis Giannakopoulos and Elias Koutsoupias. Competitive analysis of maintaining frequent items of a stream. Theoretical Computer Science, 562:23–32, 2015.
• [GKK07] D. Gavinsky, J. Kempe, I. Kerenidis, R. Raz, and R. De Wolf. Exponential separations for one-way quantum communication complexity, with applications to cryptography. In

Proceedings of the thirty-ninth annual ACM symposium on Theory of computing

, pages 516–525. ACM, 2007.
• [Hro05] JI Hromkovic. Zámecniková. design and analysis of randomized algorithms: Introduction to design paradigms, 2005.
• [IKPY17] R. Ibrahimov, K. Khadiev, K. Prūsis, and A. Yakaryılmaz. Zero-error affine, unitary, and probabilistic obdds. arXiv:1703.07184, 2017.
• [KK17a] K. Khadiev and A. Khadieva. Quantum automata for online minimization problems. In Ninth Workshop on NCMA 2017 Short Papaers, pages 25–33. Institute fur Computersprachen TU Wien, 2017.
• [KK17b] K. Khadiev and A. Khadieva. Reordering method and hierarchies for quantum and classical ordered binary decision diagrams. In Computer Science – Theory and Applications: CSR 2017 Proceedings, volume 10304 of LNCS, pages 162–175. Springer, 2017.
• [KKM17] Kamil Khadiev, Aliya Khadieva, and Ilnaz Mannapov. Quantum online algorithms with respect to space complexity. arXiv:1709.08409, 2017.
• [KMRS86] Anna R Karlin, Mark S Manasse, Larry Rudolph, and Daniel D Sleator. Competitive snoopy caching. In Foundations of Computer Science, 1986., 27th Annual Symposium on, pages 244–254. IEEE, 1986.
• [Kom16] Dennis Komm. An Introduction to Online Computation: Determinism, Randomization, Advice. Springer, 2016.
• [LG06] François Le Gall. Exponential separation of quantum and classical online space complexity. In Proceedings of the eighteenth annual ACM symposium on Parallelism in algorithms and architectures, pages 67–73. ACM, 2006.
• [M05] S. Muthukrishnan et al. Data streams: Algorithms and applications. Foundations and Trends® in Theoretical Computer Science, 1(2):117–236, 2005.
• [SS05] Martin Sauerhoff and Detlef Sieling. Quantum branching programs and space-bounded nonuniform quantum complexity. Theoretical Computer Science, 334(1):177–225, 2005.
• [Weg00] Ingo Wegener. Branching Programs and Binary Decision Diagrams: Theory and Applications. SIAM, 2000.
• [Yua09] Qingqing Yuan. Quantum online algorithms. University of California, Santa Barbara, 2009.

## Appendix 0.A Definition of OBDD and Automaton

OBDD is a restricted version of a branching program (BP). BP over a set of Boolean variables is a directed acyclic graph with two distinguished nodes (a source node) and (a sink node). We denote it or just . Each inner node of is associated with a variable . A deterministic has exactly two outgoing edges labeled and respectively for that node . The program computes Boolean function () as follows: for each we let iff there exists at least one path (called accepting path for ) such that all edges along this path are consistent with . A size of branching program is a number of nodes. Ordered Binary Decision Diagram (OBDD) is a BP with following restrictions: (i) Nodes can be partitioned into levels such that belongs to the first level and sink node belongs to the last level . Nodes from level have outgoing edges only to nodes of level , for . (ii)All inner nodes of one level are labeled by the same variable. (iii)Each variable is tested on each path only once.

A width of a program is OBDD reads variables in its individual order . We consider only natural order . In this case we denote model as id-OBDD.

Probabilistic OBDD (POBDD) can have more than two edges for node, and choose one of them using probabilistic mechanism. POBDD computes Boolean function with bounded error if probability of right answer is at least .

Let us define a quantum OBDD. That is given in different terms, but you can see that they are equivalent, see [AGK01] for more details. For a given , a quantum OBDD of width defined on , is a 4-tuple where

are ordered pairs of (left) unitary matrices representing the transitions. Here

or is applied on the -th step. And a choice is determined by the input bit. is a initial vector from -dimensional Hilbert space over the field of complex numbers. where corresponds to the initial node. is a set of accepting nodes. is a permutation of defines the order of input bits.

For any given input , the computation of on can be traced by a -dimensional vector from Hilbert space over the field of complex numbers. The initial one is . In each step , , the input bit is tested and then the corresponding unitary operator is applied: where represents the state of the system after the -th step, for . We can measure one of qubits. Let the program was in state before measurement and let us measure the -th qubit. And let states with numbers correspond to value of the -th qubit, and states with numbers correspond to value of the -th qubit. The result of measurement of -th qubit is with probability and with probability . In the end of computation program measures all qubits. The accepting (return ) probability of on input is , for .

Let if accepts input with probability at least , and if accepts input with probability at most , for . We say that a function is computed by with bounded error if there exists an such that for any . We can say that computes with bounded error .

Automata. We can say that automaton is id-OBDD such that transition function for each level is same.

## Appendix 0.B The Proof of Theorem 3.1

Let us consider any online streaming algorithm for problem. Suppose that returns value for the request of the first guardian. Let us prove that there is two parts of the input such that returns and .

Assume that there is no such triple . Then it means that we can construct streaming algorithm that uses space less than bits and such that iff . The algorithm emulates work of the algorithm . It means that computes or . In the case of , we can construct such that . It is contradiction with the claim of the theorem.

By the same way we can show that for there are triples .

Let us choose , for .

Let us consider an input . Optimal offline solution is where

Let us prove that for each . We have , therefore , so .

Therefore, all answers are wrong and . So competitive ratio cannot be less than .

## Appendix 0.C The Proof of Theorem 3.2

We can show that algorithm cannot compute any with bounded error. The idea of proof is similar to proof of Theorem 3.1. It means that only way to answer is guessing with probability . So, the cost of -th block , because the algorithm should guess all output bits for getting cost . Therefore, . So competitive ratio is such that .

## Appendix 0.D The Proof of Theorem 3.3

Let us show that we can suggest an input such that at least guardians returns wrong answers. Let the algorithm receives the input , such that . Let be such that for . Then receives the part of the input and returns . Let , if ; and , otherwise. Then we choose such that . In that case . Therefore at least guardians return wrong answers. The worst case is the first guardians returns wrong answer. So, blocks will be ”wrong”. And competitive ratio . Hence and is -competitive in case of . And , for odd , and is -competitive in case of .

## Appendix 0.E The End of The Proof of Theorem 3.4

The probability of the event is: