Proof verification of Exercise 4.4 of Baby Rudin (see details) 
$f$ and $g$ are continuous mapping of a metric space X into metric space Y and $E$ is dense subset of X. If $g(p)=f(p)$ for all $p\in E$, prove that $g(p)=f(p)$ for all $p\in X$.

My approach:
We need to prove $g(p) = f(p)$ only for elements $p\in E'$ as it is true for elements of E and X is union of $E$ and $E'$ as E is dense in X.

Claim: If $p\in E'$, then $g(p)=f(p)$

$p\in E'$
$\therefore$ $p$ is limit point of set E. So there exists a sequence such that $\lim_{n\to\infty} p_n = p$. All terms of this sequence will be in E. $\therefore$ $g(p_n)=f(p_n)$ for all positive integer n. 
Now, $f$ and $g$ are continuous functions on metric space X so
$$\lim_{n\to \infty } g(p_n) = g(p)$$
$$\lim_{n\to \infty } f(p_n) = f(p)$$
But both sequence $g$ and $f$ are equal. Also limit point should be unique.
$$f(p) = g(p)$$
Is it valid?
 A: This is correct and is likely the approach Rudin had in mind. However there is an alternative argument that is instructive and doesn't rely on sequences.

If $f,g:X\to Y$ are continuous and $X,Y$ are metric spaces, then the set $F:=\{x \in X \mid f(x)=g(x)\}$ is closed.

Proof:
Suppose $x\not\in F$. Then $f(x)\ne g(x)$, so there exists $\varepsilon>0$ such that $B_\varepsilon(f(x))$ and $B_\varepsilon(g(x))$ are disjoint. By the continuity of $f$ and $g$, there exists $\delta>0$ such that $f(B_\delta(x)) \subseteq B_\varepsilon(f(x))$ and $g(B_\delta(x))\subseteq B_\varepsilon(g(x))$. Thus $y\in B_\delta(x)$ satisfies $f(y)\ne g(y)$ because
$f(y)\in B_\varepsilon(f(x))$ and $g(y)\in B_\varepsilon(g(x))$, and $B_\varepsilon(f(x))$ and $B_\varepsilon(g(x))$ are disjoint. Hence
$B_\delta(x)\subseteq F^c$, which proves that $F^c$ is open. $\square$
From this result the problem follows because you are given
$E\subseteq F$, and so the fact that $E$ is dense and $F$ is closed implies $X=\overline{E}\subseteq F$.
One motivation for this approach is that it can be easily generalized to topological spaces:

If $f,g:X\to Y$ are continuous, where $X$ is a topological space and $Y$ is Hausdorff, then $\{x \in X \mid f(x)=g(x)\}$ is closed.

