Recurrence formulae help

32 Views Asked by At

I need help with the following recurrence problem. Suppose we have a vector with n integers $\langle x_1,x_2,\ldots,x_n\rangle$. For this vector we calculate the relative parts of the even numbers and the odd numbers: $$m_0= \frac{\text{number of even}}{n}$$ $$n_0=\frac{\text{number of odd}}{n}$$ The the first number $x_1$ is deleted and a new number $x_{n+1}$ is added so that the vector becomes $x_2,x_3,\ldots,x_n, x_{n+1}$. We calculate again $$m_1=\frac{\text{number of even}}{n}$$ $$n_1=\frac{\text{number of odd}}{n}$$ The question is how having calculated $m_0, n_0, m_1, n_1$ to obtain the numbers $$m'=\frac{\text{total number of even including the deleted}}{n+1}$$ $$n'=\frac{\text{total number of odd including the deleted}}{n+1}.$$

1

There are 1 best solutions below

1
On

It is impossible. Suppose that the initial vector is $(1,0,1)$. Then $m_0=1/3$, $n_0=2/3$. Now, let's delete the first $1$ and add a append a new one to get $(0,1,1)$. Now, $m_1=1/3$, $n_1=2/3$. And $m'=1/4$, $n'=3/4$. That is, $$\left. \begin{array}{r} m_0=1/3\\n_0=2/3\\m_1=1/3\\n_1=2/3 \end{array}\right\rbrace\Rightarrow \left\lbrace \begin{array}{l} m'=1/4\\n'=3/4 \end{array}\right.$$

Now, suppose that the initial vector is $(0,1,1)$, we delete the $0$ and append another $0$. Now you get: $$\left. \begin{array}{r} m_0=1/3\\n_0=2/3\\m_1=1/3\\n_1=2/3 \end{array}\right\rbrace\Rightarrow \left\lbrace \begin{array}{l} m'=1/2\\n'=1/2 \end{array}\right.$$

That is, with same input you should get different outputs. The reason for that behaviour is that if $n_0=n_1$, we know that the deleted and the appended number have the same parity, but we don't know, in general, if they are even or odd.