The proof of the countability of a set Let a function $f: A \rightarrow R $ be defined on $A$ and have a local extremum at each non-isolated point of this set. How to prove that the set $ f (A)$ is either finite or countable?
 A: The result is true for any function $f:\mathbb R\to \mathbb R.$ To see this, fix $n\in \mathbb N.$ Then let $A_n=\{x\in \mathbb R: |x-y|<1/n \Rightarrow f(y)<f(x)\}.$ Now, let $k\in \mathbb N$ and define $I_{nk}:=\left [\frac{k}{2n},\frac{k+1}{2n}\right ].$ Then, $I_{nk}\cap A_n$ is either empty or a singleton. Hence, $A_n=\bigcup_kI_{nk}\cap A_n$ is countable, and therefore so is $A=\bigcup_n A_n.$ To finish, note that $A$ is precisely the set of all local maxima for $f$.
A: Let me give you a hint. I assume that $A\subseteq \mathbb{R}$. 
Fact.
Suppose that $A\subseteq \mathbb{R}$. Every function $f:A\rightarrow \mathbb{R}$ can have at most countably many local extrema.
Indeed, for every local maximum $a$ pick an open interval $U_a$ with both endpoints being rational numbers such that $a\in U_a$ and $f(a) > f(x)$ for $x\in U_a\setminus \{a\}$. This gives an injection
$$\big\{\mbox{ local maxima }\big\}\rightarrow \big\{\mbox{ open intervals of }\mathbb{R}\mbox{ with both endpoints rational}\big\}$$
This shows that the set of local maxima is at most countable. We deal similarly with local minima. 
Remark. The result holds, if we replace $A\subseteq \mathbb{R}$ by any second countable topological space $X$.
In general using the fact you can prove that if there exists a function $f:X\rightarrow \mathbb{R}$ defined on a second countable space $X$ such that each nonisolated point of $X$ is a local extremum of $f$, then $X$ is at most countable (and hence $f(X)$ is at most countable too).
