General structure of the proof that every compact metric space is the continuous image of the Cantor set
Solution 1:
The general outline is to write your given compact metric space $A$ as a decomposition into two sets, then four sets, then eight sets, etc., in the exact same fashion that the Cantor set is decomposed, except that whereas the decomposition elements of the Cantor set are pairwise disjoint, the decomposition elements in $A$ need not be pairwise disjoint. Be careful about how your decomposition elements are indexed. Once similarly indexed decomposition elements of $C$ and of $A$ are put side-by-side, the formula for writing the desired function $C \mapsto A$ is evident.
Here's a few details.
For any compact metric space $A$, you can write it as a union of two compact subsets $$A = A_0 \cup A_1 $$ and then for each $i_1 \in \{0,1\}$ you can write $A_{i_1}$ as a union of two compact subsets $$A_{i_1} = A_{i_1,0} \cup A_{i_1,1} $$ and then for each $i_1,i_2 \in \{0,1\}$ you can write $A_{i_1,i_2}$ as a union of two compact subsets $$A_{i_1,i_2} = A_{i_1,i_2,0} \cup A_{i_1,i_2,1} $$ and so on and so on inductively, so that as the length of the subscript sequence increases, the diameter of the set decreases to zero. It follows for any infinite sequence $\omega = (i_1,i_2,i_3,...)$ of $0$'s and $1$'s the nested decreasing intersection $$A_\omega = A_{i_1} \cap A_{i_1, i_2} \cap A_{i_1, i_2, i_3} \cap \cdots $$ is a single point.
Then you take the usual description of the Cantor set $C$ as the set of real numbers $x$ written in trinary as $$x = .j_1 j_2 j_3 \cdots $$ where $j_n \in \{0,2\}$, let $i_n = j_n/2 \in \{0,1\}$, let $\omega(x) = (i_1,i_2,i_3,...)$, and map $x$ to the point $A_{\omega(x)}$.
Solution 2:
Let $X$ be a compact metric space. The key point is that we can subdivide $X$ into smaller and smaller regions, such that at each stage there are only finitely many regions total.
Specifically, we want for each $n$ a partition
$$X=Y^n_1\sqcup . . . \sqcup Y^n_{k_n}$$ of $X$ such that each $Y^n_i$ has size (that is, diameter) less than (say) $2^{-n}$. If we can do this, then
Each element $x$ of $X$ is determined by the sequence of pieces which contain $x$ (that is, the sequence $s_x$ whose $n$th term is $j$ iff $x\in Y^n_j$).
Since there are only finitely many pieces at each stage, we can view this as a representation of $X$ as the set of paths through a finitely branching tree.
I'm skipping a bunch of things here, but this is the general idea.
Solution 3:
The essential property is that given a compact metric space $X$ and $r>0$ there is a finite number of balls covering $X$. Let $0<\lambda<1$ and make the simplifying assumption that $X$ may be covered by two closed balls $B_0$ and $B_1$ of size 1. Then assume (again for simplicity) that each of $\Lambda_0=B_0$ and $\Lambda_1=B_1$ (both are compact since closed) may be covered by two closed balls $B_{00}, B_{01}$ and $B_{10},B_{11}$, respectively, of size $\lambda^1$. We set $\Lambda_{i_1i_2}= B_{i_1}\cap B_{i_1i_2}$. Proceeding inductively we assume that $$\Lambda_{i_1...i_{n-1}}=B_{i_1}\cap ...\cap B_{i_1 ... i_n}$$ is non-empty (finite intersection property, FIP) and may be covered by two closed balls $B_{i_1...i_{n}0}$ and $B_{i_1...i_n 1}$ of radius $\lambda^n$.
If all this is possible then for every infinite sequence $s=(i_1i_2...)\in \Sigma =\{0,1\}^{\mathbb N}$ there is a unique intersection point $$\{\phi(s)\}=\cap_n \Lambda_{i_1... i_n} $$ (this follows from compactness and the FIP). The map $\phi: \Sigma \rightarrow X$ is continuous for the weak topology on $\Sigma$ (simply because the balls are shrinking). It is surjective since given $x\in X$ for each $n$ the set $$F_n(x)=\{ (i_1,i_2,...)\in \Sigma: x\in \Lambda_{i_1,...,i_n}\}$$ is a shrinking sequence of compact non-empty subsets of $\Sigma$. Again from compactness, but this time of $\Sigma$, the intersection $F(x)=\cap F_n(x)$ is non-empty and $\phi(s)=x$ for each $s\in F(x)$. So $X$ is the continuous image of the Cantor set $\Sigma\ $ (if you agree to this being a representation of a Cantor set?). In general the map is not bijective.
Difficulties arise because you may need more than two balls in each step of refinement (so you have to use trunks of symbols). Also some of the sets $\Lambda_{i_1...i_n}$ may suddenly turn out to be empty. So you need to decide what to do then. Hope nevertheless that the above may give an idea ? Obviously the answer ressembles previous ones already given...