0
$\begingroup$

I am trying to understand randomized AND-OR Game Tree Evaluation. I am stuck with proving the most basic case, namely, an OR node with two leaves (AND node with two leaves is similar).

                          (OR) = 1
                          /  \
                         /    \
  Possible inputs:      1      1
                        0      1
                        1      0

You can find detailed description of the problem in this lecture notes or in Randomized Algorithms, pg. 29, by Motwani&Raghavan. Basically, given the OR-node and inputs $0$ or $1$ we evaluate the value of the OR-node by inspecting the input values (leaves). For example if the input is $1$ and $0$ then after reading the first value, $1$, we do not need to read the second value, and hence only one read will need to be done. On the other hand, if the input is $0$ and $1$ then after the reading the first value we still need to read the second value (since it may be equal to $1$).

Randomized version of evaluation tosses an unbiased coin and with probability $0.5$ reads the first input value or the second. So, the problem is, given that the OR-gate has output $1$, to compute the expected number of reads.

Both the lecture notes and the book computes it as following

If the node is to return a $1$, then at least one of the leaves must return a $1$. With probability $1/2$ this leaf will be selected first and only one evaluation will need to be done. The other possibility (also occurring with probability $1/2$) is that both leaves will need to be evaluated. The expected number of evaluations, $E^{OR}_1$, is given by $$ E^{OR}_1 = \left(\frac{1}{2} \times 1\right) + \left(\frac{1}{2} \times 2\right) = \frac{3}{2}$$

However, I compute it differently. The probability that a certain leaf is selected is $1/2$, but since we have three possible inputs the probability that the selected leaf has value $0$ is different from the probability that it is $1$. In particular $P(value=1)=2/3$ and $P(value=0)=1/3$. In other words, the probability that a leaf with $1$ will be selected is slightly greater than $1/2$. I'm probably missing something. Could someone explain what is wrong with my approach?

$\endgroup$
  • $\begingroup$ avoid using mathjax in titles. $\endgroup$ – virmis_007 Jan 27 '18 at 9:34
1
$\begingroup$

When you talk about probabilities, you should first decide what is actually random. Note that there are two possible sources of randomness here, the value of the leaves (i.e. were talking about some distribution over the possible inputs), and the random choice of what leaf to evaluate first (i.e. inner randomness of your algorithm).

When we say our algorithm is randomized, we usually mean the latter. The complexity of such an algorithm is considered with respect to the worst possible input. More formally, saying that the algorithm runs in expected time $T$, means that $T=\max\limits_{i\in I}\mathbb{E}\left[T(i)\right]$, where $I$ is the set of possible inputs and $T(i)$ is the running time on input $i$ (which is a random variable, since we have a coin-tossing algorithm). This is a worst case complexity measure, as the probabilistic analysis is done relative to the worst possible input. Here the worst case (conditioning on the output being $1$) is that exactly one leaf evaluates to $0$, and in this case the expected number of evaluations is indeed $\frac{3}{2}$.

The analysis you described corresponds to the former option, i.e. we are interested in average-case complexity, relative to the uniform distribution over possible inputs (so we actually have two sources of randomness here). In this case, conditioning on the output being $1$, you are right to say that the value of a leaf is $1$ with probability $\frac{2}{3}$, which makes the expected running time $\frac{4}{3}$ (where the expectation is taken over the leaves values and the coin outcome).

$\endgroup$
  • $\begingroup$ Thanks for the answer. So, as far as understoond if we don't condition on the output being $1$ or $0$ then the worst case input would be $0$ and $0$ and so its expected running time would be $2$ (with the probability $1$ the algorithm chooses a leaf with $0$ resulting in two reads). Am I on the right track? $\endgroup$ – HardFork Jan 29 '18 at 23:38
  • 1
    $\begingroup$ Yes. Need more characters $\endgroup$ – Ariel Jan 30 '18 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.