Expectation when n items have different probabilities p1, p2, ...., pn 
A list contains $n$ items in random order. To find an item in a list,
the list is searched sequentially until  the  desired  item  is
found.   What  is  the  expected  number  of  items  searched  before
the desired item is found if all items are equally likely to be the
one sought?

I was able to find that the expectation is equal to $(n+1)/2$ in this case.

If the items are instead requested with known probabilities
$p_1,p_2,...,p_n$,  suggest a better alternative algorithm and show it has
a shorter expected number of items searched.

This is where I am struggling right now. I can guess that in this case the expectation would likely be: $\sum x_ip_i$.
But I don't know how I can show that it is a shorter expectation than the one I found in the first part.
Please help me understand that.
 A: Indicator variable method:
Let $X_i$ = $1$ if we end up searching object $i$ and $0$ otherwise. In the initial case it is clear to see , from the uniform indifference, that the probability each object is seen in a search (aside from the object we actually are looking for) is $\frac{1}{2}$. And hence $\mathbb{E}[X_i] = \frac{1}{2} $ for $i \not = $ desired object.

You can think of the problem as how many horses finish before a given horse when they all have the same speed.
Let $N$ denote how many objects we search.
The total number of searched objects when looking for object $j$ is $1+ \sum_{i \in [1,n] \setminus j  } X_i$
$N = 1+\sum_{i \in [1,n] \setminus j  } X_i$ and so $\mathbb{E}[N] = 1 + \sum_{i \in [1,n] \setminus j  } \mathbb{E}[X_i] = 1 +\frac{n-1}{2} = \frac{n+1}{2}$ as you already noted.
For you second case we only slightly modify above work. What is the probability we find object $i$ before object $j$ when they have respective probabilities $p_i,p_j?$
$\frac{p_i}{p_i+p_j}$ (condition recursively  on the first searched object)
Can you continue from here?
