\documentclass[a4paper,12pt]{article}
\newcommand{\ds}{\displaystyle}
\begin{document}
\parindent=0pt

 {\bf Question}

 A man with $n$ keys wants to open his door and tries the
keys at random.  Exactly one key will open the door.  Let $X$
denote the number of trials required to open the door for the
first time. Find $E(X)$ if

\begin{description}
\item[(a)]
unsuccessful keys are not eliminated from further selections

\item[(b)]
unsuccessful keys are eliminated
\end{description}

\medskip

 {\bf Answer}

 Let $X$ be the number of trials needed to open the door.  Let
$`S'$ denote success i.e. the door is opened and $`F'$ denote
failure for each trial.

\begin{description}
\item[(a)]
The event $X=x$ is equivalent to the event $\underbrace{F\ F\ F\
\ldots\ F}_{x-1\ \mathrm{times}}S$

Also $P(S)=\ds \frac{1}{n}$ and $P(F)=\ds \frac{n-1}{n}$.

$X$ has the geometric distribution with $p=P(S)=\ds \frac{1}{n}$.

Therefore $\ds E(X)=\frac{1}{p}=\frac{1}{\frac{1}{n}}=n$

\item[(b)]
If unsuccessful keys are eliminated then it can take at most $n$
attempts to open the door with the following probabilities:

\begin{eqnarray*}
P(X=1)&=&\ds \frac{1}{n}\\ P(X=2)&=& \ds \frac{n-1}{n} \cdot
\frac{1}{n-1} = \ds \frac{1}{n}\\ P(X=3)&=& \ds \frac{n-1}{n}
\cdot \frac{n-2}{n-1} \cdot \frac{1}{n-2} = \ds \frac{1}{n}\\
&\vdots&\\ P(X=n)&=& \ds \frac{n-1}{n} \cdot \frac{n-2}{n-1} \cdot
\frac{n-3}{n-2}...\ \cdot \frac{1}{2} \cdot 1 = \ds \frac{1}{n}.
\end{eqnarray*}

Therefore $E(X)=\ds 1 \cdot \frac{1}{n} + 2 \cdot \frac{1}{n} +
...\ n \cdot \frac{1}{n} = \ds \frac{n(n+1)}{2n} = \ds
\frac{n+1}{2}.$
\end{description}

\end{document}
