Let $x_0 =0$ and let $x_1,.....x_{10}$ satisfy that $|x_i - x_{i-1}|$ = 1 for 1≤i≤10 and $x_{10} = 4$ . How many such sequences are there satisfying these conditions?
I tried to calculate it by backtracking from $x_0$ and $x_{10}$, and built an entire tree for the possible values. Based on the edges of the trees, I calculated the answer to be $2*4*6*7*7*7*7*6*4*2$ but the answer is clearly wrong. The question is supposed to be a probability question, but I was thinking of trying to solve it using dynamic programming. It is supposed to be an easy question though, can anyone help me out?
$x_i$ is either $x_{i - 1} + 1$ or $x_{i - 1} - 1$, right?
Then this is equivalent to you perform $+1$ or $-1$ by $10$ times, and expecting a result of $4$.
Simple calculation: If we choose to $+1$ by $x$ times, then $-1$ should be $(10 - x)$ times, and the result is $x \cdot (+1) + (10 - x) \cdot (-1) = 2 x - 10$, to ensure this equal to $4$, we must have $x = 7$.
Then the problem is to choose $7$ positions among $10$, and assign them to be $+1$, the rest $3$ positions are assigned by $-1$.
The answer is $\dbinom{10}{7} = 120$.