What is the difference between dense and closed sets? I am self studying topology and is a bit stuck on the difference between dense and closed sets. Intuitively, a dense set is a set where all elements are close to each other and a closed set is a set having all of its boundary points. 
But to make this more concrete, can someone give me an example of a closed set that is not dense and a dense set that is not closed?
Thanks!
 A: A set is dense/closed in a given topological space.
$[0,1]$ is closed in $\mathbb{R}$ but it is not dense in $\mathbb{R}$ since there are real numbers that can not be approached arbitrarily close by elements of $[0,1]$.
$[0,1]\setminus\{\frac{1}{2}\}$ is dense in $[0,1]$ but it is not closed in it.
A: Take $\mathbb R$ with the usual topology. Then the set of integers is closed (any converging series of integers converges to an integer), but not dense (you get nowhere close to $1/2$). On the other hand, the set of rational numbers is dense, but not closed (the limit of a sequence of rational numbers can be irrational).
IMHO a good intuition for a closed set is that while staying in the set, you cannot get arbitrary close to any point outside of that set. Which is actually the exact opposite to a dense set which gets close to each point of the space.
With that intuition it's also immediately clear why the only closed dense set is the space itself: The only way to come close to each point without coming close to any point outside of the set is if there are no points outside of the set.
A: $[0,1]$ is a closed subset of $\mathbb R$ that is not dense.  It contains all of its limit points, so it is closed.  Some points in $\mathbb R$, for example $2$, are not limit points of this set, so the set is not dense.
$\mathbb Q$ is a dense subset of $\mathbb R$ that is not closed. It is not closed because it does not contain all of its limit points.  For example $\sqrt 2$ is a limit point of this set because every open neighborhood of $\sqrt 2$ contains some rational numbers.  It is dense because every point in $\mathbb R$ is one of its limit points.
A: I'd say the most glaring difference between the two definitions is that dense sets need not contain their limit points. Closed sets necessarily do. There are plenty of examples of "dense not closed" and "closed not dense" scattered throughout this question now. 
I'd also argue that your intuition for a dense set only makes sense in spaces where distance makes sense, like $\Bbb{R}^n$. As long as that helps you warm up to the definition, that's good. But in more general spaces things won't be that intuitive. For example, the set $X=\left\{\square ,\triangle\right\}$. A topology for the set is $$\mathcal{T}=\left\{\emptyset, \left\{\square ,\triangle\right\},\left\{\square\right\} \right\}$$ We see that $\square$ is open in $X$ and that $\text{Cl}(\square) = X$ so $\square$ is dense in $X$. But "closeness" doesn't mean a whole lot either.
A: I want to add one thing. The only closed, dense set in a topological space is the space itself!
So these two concepts are pretty far apart. So far that in most situations, they are mutually exclusive!
A: Let the metric space be $\mathbb{R}$. Then $\{0\}$ is closed but not dense in $\mathbb{R}$. While $\mathbb{Q}$ is dense but not closed in $\mathbb{R}$.
A: Loosely speaking:
Suppose $X$ is a topological space (with some topology, obviously).
If $A \subseteq X$ and we say $A$ is dense in $X$, we mean that for each point $x \in X$, we can keep finding points from $A$ "closer" and "closer" to $x$.  
If $B \subseteq X$ and we say $B$ is closed in $X$, we mean if you can find points in $X$ that are really really close to elements of $B$, then those points from $X$ are also in $B$.  In other words, if $y$ is an element that is not in $B$, then none of the points nearby it are in $B$ either (otherwise, if we could keep finding stuff from $B$ closer and closer to $y$, then $y$ would be in $B$).
A: In a topological space $(X,\tau)$ a subset $A \subset X$ is dense, iff its closure is the whole space, i.e. $\overline{A} = X$, while a subset $B \subset X$ is closed iff it is its own closure, i.e. $\overline{B} = B$.
To recite the example of $\mathbb{R}$ with euclidian topology:


*

*$\mathbb{Q} \subset \mathbb{R}$ is dense but not closed, since:
$\overline{\mathbb{Q}} = \mathbb{R}$.

*$[0,1] \subset \mathbb{R}$ is closed but not dense, since $\overline{[0,1]} = [0,1]$.

A: One explanation is in terms of continuous functions.
A continuous function (on a topological space $X$) is determined by its values on a dense subset of $X$.  This is a defining characteristic of dense sets; any non-dense subset does not have this property.
A prototype of a closed subset of $X$ is the solution set of a collection of equations defined by continuous functions; more abstractly, the set of points where a continuous function (from $X$ into some other topological space $Y$) attains a particular value.  This might encompass all closed subsets under some fairly general hypotheses that endow $X$ it with "enough" continuous functions, or maybe allowing arbitrary $Y$ is enough.  This picture is made precise in a more advanced setting by dualities between algebras of functions and topological (or geometric, or algebra-geometric, ....) spaces.
A: No one talk about Zarisky topology so I wanted to write it. Zariski topology is taught at the beginning of algebraic geometry. Let $k$ be algebraically closed field and $\mathbb{A}^n_k$ is the set of all elements $(a_1,...,a_n)$ where $a_i's \in k$. In Zarisky topology, the closed sets are the zero set of ideals of $k[x_1,...,x_n]$.
In this topology, in $\mathbb{A}^n_k$, there is only one dense and closed set which is $\mathbb{A}^n_k$. The other closed sets are not dense. Besides, all nontrivial open sets are dense in this topology.
