Let $(X, d)$ be a metric space. Let $K$ be a compact subset of $(X, d)$. Show that any $f: K \rightarrow \mathbb{R}$ that is continuous (w.r.t. the metric $d$ on $K$, and the usual metric on $\mathbb{R}$) has a maximal value.
Here, we essentially want to show $f(K)$ has a maximum, right? Since $K$ is compact, we know it's closed and bounded. Since $K$ is bounded, there is some $m \in K$ s.t. $\forall k \in K$, $k \le m$. Now, how do I make the connection between $K$ having a maximal element and the fact that $f(K)$ also has a maximal element? I'm not sure if I really understand compact sets properly. Any help would be greatly appreciated. Thank you.
$X$ is a general metric space, not necessarily the real line, so there is no sense of "maximal". Even further the result that if $K \subset X$ is compact then $K$ must be closed requires $X$ to be a Hausdorff space.
Instead the main result is that continuous functions map compact spaces to compact spaces. Hence $f(K)$ is compact in $\mathbb R$. Now we can finish the proof using your argument that $K$ has a maximal element, just applying it to $f(K)$ instead.