5. Random walk of a point. A point exits from the origin on a line and makes $a$ steps one unit to the right, $b$ steps one unit to the left in some order, where $a>b$. The range of the point's walk is defined as the difference between the greatest and the smallest coordinates of the point over the entire walk.

a) Find the greatest possible range of the walk.

b) Find the smallest possible range of the walk.

c) How many different sequences of movements of the point exist such that the range of the walk is the greatest possible?
Solution. Let's solve all three problems at once. At the end of its path, the point inevitably (regardless of the order of steps to the right and to the left) has the coordinate $a-b$. Therefore, the greatest span can be $a$, and the smallest span can be $a-b$.

The greatest span is achieved if all steps to the right are made consecutively. The first step to the right can be the first, second, and so on up to the $(b+1)$-th step (first $b$ steps to the left, and then all steps to the right). Thus, there are $b+1$ ways.

The smallest span is achieved, for example, as follows: the point moves right-left exactly $b$ times, and then $a-b$ times to the right.

Answer: a) $a ;$ b) $a-b ; \mathbf{c)} b+1$.