Are there any non-compact topologies such that every real-valued continuous function has a maximum value? I asked my topology teacher this and she didn't know.
Does there exist a non-compact topology $E$ such that for every continuous function $f : E \to \mathbb{R}$, $\text{max}(f(E))$ exists?
 A: Let me try to describe an example based on the existence of the first uncountable ordinal.
By that I mean a set $W$ equipped with an order relation "$\le$" which makes it a well ordered set, i.e. every non-empty subset has a minimum element (such as $\mathbb N$), and which also satisfies:

*

*$W$ is uncountable,

*for every $x$ in $W$, the set $$I_x:=\{y\in W: y\le x\}$$ is countable.

Let me assume the existence of $W$ and carry on, but I'll be happy to indicate a way to construct it.
Ok, so let's consider the smallest topology on $W$ relative to which the intervals
$$(a,b) = \{x\in W: a<x<b\} $$
are open.  Here we allow $a=-\infty$, or $b=\infty$, with the usual interpretation of infinite intervals.
One important fact we need to use is that every subset $I_x$, as above, is compact (can you prove it?).
Lemma.  Every non-decreasing function $f:W\to \mathbb R$ is bounded above.
Proof.  Suppose by contradiction that $f:W\to \mathbb R$ is non-decreasing and unbounded.  So, for each $n\in\mathbb N$, we may choose $a_n\in W$, such that $f(a_n)\ge n$.
We then claim that $W=\bigcup_n I_{a_n}$.  To see this, pick any $x\in W$ and choose some integer $n>f(x)$.  Observing that every $y\le x$ satisfies $$f(y)\le f(x)<n,$$ we see that $a_n$ cannot be $\le x$, meaning that $a_n>x$, so $x\in I_{a_n}$.
Since each $I_{a_n}$ is countable, we deduce that $W$ itself is countable, a contradiction.  QED
Theorem. $W$ is pseudo compact, that is, every continuous function $f:W\to\mathbb R$ is bounded above. However $W$ is not compact.
Proof.  For each $x$, let $$M_x=\sup_{y\in I_x} f(y),$$ which is a finite real number since $I_x$ is compact.
The function $x\in W\mapsto M_x\in\mathbb R$ is then clearly non-decreasing, hence bounded by the Lemma.  This obviously implies that $f$ is bounded above.
To show that $W$ is not compact, notice that it cannot have a maximum element $x$, or else $W=I_x$ is countable.
Therefore $W$ is covered by the open sets $(-\infty,x)$, as $x$ range in $W$, but this cover clearly has no finite sub cover.
QED
Finally, let's show that every continuous real function $f$ on $W$ attains it's maximum.
To see this, suppose otherwise, and let $M$ be the supremum of $f$ on $W$ (which we already know is finite).
It then follows easily that
$$g(x):= \frac 1{M-f(x)}$$
is continuous and unbounded, violating the Theorem!
A: I'd like to add some information to what @Ruy wrote, for better understanding.
According to his notation, we can put $W=[0,\omega_1)$, i.e. the set of ordinal numbers smaller than $\omega_1$ - the smallest uncountable ordinal number. It can be proved that the set $[0,\omega_1]=W\cup\{\omega_1\}$ is a compact space (with order topology).
One can give another ending of the @Ruy reasoning. Namely, since $M_x$ is bounded above and $\sup_xM_x = M$, for any $n\in\Bbb N$ there's an ordinal number $x_n\in W$ such that $M_{x_n}>M-\frac 1n$. Define $x_0:=\sup x_n$ (supremum in ordinal numbers set). It's a countable number so $x_0<\omega_1$, so $x_0\in W$. For $x>x_0$ the function is constant (is equal to $M$). This is important in some considerations. Particularly, this function can be extended to a continuous function on $[0,\omega_1]$ by putting $f(\omega_1)=1$.
