Countability of local maxima on continuous real-valued functions I am working through a bank of previous exams and couldn't figure a problem out to my satisfaction.

Let $f(x) : \mathbb{R} \to \mathbb{R}\,$ be a continuous function.
  
  
*
  
*Show that $f$ can have at most countably many strict local maxima.
  
*Assume that $f$ is not monotone on any interval. Then show that the local
  maxima of $f$ are dense in
  $\mathbb{R}$.
  

 A: *

*For each $\delta>0$, the set of all $x\in\mathbb{R}$ such that $f(y)<f(x)$ for all $y$ with $0<|x-y|<\delta$ is countable.  This can be seen by noting that the set contains at most one element of the interval $[k\frac{\delta}{2},(k+1)\frac{\delta}{2}]$ for each integer $k$, and these intervals cover $\mathbb{R}$.  The set of strict local maxima is a countable union of such sets, for example taking $\delta=\frac{1}{n}$ as $n$ ranges over the positive integers.

*Suppose that $f$ is a continuous function that is not monotone on any interval.  We want to show that $f$ has a local maximum in every interval.  The argument is the same if the interval is $(0,2)$, so to slightly reduce notation let's work there.  Note that not being monotone in any interval means that each interval contains pairs $x_1<x_2$ and $y_1<y_2$ such that $f(x_1)<f(x_2)$ and $f(y_1)>f(y_2)$.  So $(0,1)$ contains a pair $x_1<x_2$ such that $f(x_1)<f(x_2)$, and $(1,2)$ contains a pair $y_1<y_2$ such that $f(y_1)>f(y_2)$.  Because $f$ is continuous, there is a point $x_0\in [x_1,y_2]$ where $f$ has its maximum value.  Because $f(x_2)>f(x_1)$ and $f(y_1)>f(y_2)$, $x_0$ is not an endpoint of $[x_1,y_2]$.  Therefore $f$ has a local maximum at $x_0$.
