The problem statement: Repeatedly pick a random number (uniformly-distributed) between $0$ and $1$. Keeping going while the second number is smaller than the first, the third number is larger than the second, the fourth number is smaller than the third, the fifth number is larger than the fourth, etc. In other words, the numbers must alternate between decreasing and increasing. Stop when this alternating pattern is broken. What is the expected value of the number of random numbers picked?
I would think that the problem requires integrals, specifically integrating the expected value over $0$ to $1$. However, I am stuck at arriving at this expected value, since, if $x_0, x_1, x_2, \cdots, x_n$ is the sequence of numbers picked, the probability is $1-x_0$ that the number of numbers picked is $2$, the probability is $x_1$ that the number of numbers picked is $3$, the probability is $1-x_2$ that the expected number of numbers picked is $4$, the probability is $x_3$ that the number of numbers picked is $5$, etc. I can't figure out how to set up an integral from this. Any ideas?

A key realization here is that the numbers themselves don't matter, and neither does the fact that this is a uniform distribution. The answer would be the same for any continuous distribution. All that matters is the rank ordering of the numbers. Given that any N distinct numbers were chosen, all $N!$ orderings of those numbers have equal probability. So the problem reduces to counting the ways $A_N$ to arrange the $N$ integers $1,2,\dots,N$ in such a way that they alternate decreasing and increasing starting with decreasing. Then our answer is simply
$$E(picks) = 2 + \sum_{k=2}^{\infty}P(N \gt k)$$
$$=\sum_{N=0}^{\infty}\frac{A_N}{N!}$$
where $A_0 = 1$, and $A_1 = 1$, and we can easily verify
$A_2 = 1$
$A_3 = 2$
$A_4 = 5$
$A_5 = 16$
These produce the terms
$1 + 1 + 1/2 + 1/3 + 5/24 + 2/15 + \dots$
consistent with what has been computed previously. Determining the others is a well-known combinatorics problem known as counting alternating permutations or André's problem whose sequence is given by AEIS A000111 and known as the Euler zigzag numbers:
1, 1, 1, 2, 5, 16, 61, 272, 1385, 7936, 50521, 353792, 2702765, 22368256, 199360981, 1903757312, 19391512145, 209865342976, 2404879675441, 29088885112832, 370371188237525, 4951498053124096, 69348874393137901, 1015423886506852352, 15514534163557086905, 246921480190207983616, 4087072509293123892361, ...
Using these values gives an expected value of approximately $3.41$ picks, in agreement with simulation. The generating function for these numbers turns out to be sec(x) + tan(x), so the exact answer is sec(1) + tan(1).
This problem should be tagged for combinatorics, permutations, alternating permutations, Euler zigzag numbers, and Andrés problem.