Spaces $X$ in which every subset is either open or closed, and only $\varnothing$ and $X$ are clopen Let $(X, \tau)$ be a topological space. Then $X, \varnothing \in \tau$ and are both clopen.
But I wonder if it is possible to construct a topological space $X$ in which all subsets are either open or closed, but $X$ and $\varnothing$ are the only clopen subsets.
 A: Let $X$ be an infinite set, and let $\mathcal U$ be a ultrafilter on $X$.  Then $\mathcal T = \mathcal U \cup \{ \emptyset \}$ is a topology on $X$ in which every subset of $X$ is either open or closed, and $\emptyset$ and $X$ are the only clopen subsets.
That it is a topology follows from the fact that $\mathcal U$ is a filter, so is closed under finite intersections, and as every superset of an element of $\mathcal U$ is an element of $\mathcal U$, $\mathcal U$ is clearly closed under arbitrary unions.
That $\mathcal U$ is an ultrafilter implies that every subset is either open or closed, and also implies that $\emptyset$ and $X$ are the only clopen subsets (since if $A$ were another clopen subset, then both $A$ and $X \setminus A$ would belong to $\mathcal U$, meaning that $\emptyset = A \cap ( X \setminus A ) \in \mathcal U$, contradicting our assumption that $\mathcal U$ is an ultrafilter).
(If $\mathcal U$ were a principal ultrafilter, we would get the same topology described in N. S.'s answer.)
A: Yes, for example $X = \{0, 1\}$ with the topology $\tau = \{ \emptyset, \{0\}, \{0, 1\}\}$.
A: The spaces where every set is either open or closed are called door spaces. The spaces where the empty set and the whole space are the only clopen sets are called connected spaces. So you are asking about connected door spaces. They are in fact fully classified. There are no other such spaces then already mentioned examples – the empty space, principal ultrafilter spaces i.e. included point topologies, free ultrafilter spaces, principal ultraideal spaces i.e. excluded point topologies.
A: Sure.
$$X=\emptyset, \tau = \{\emptyset\}$$

That's cheating!!!
OK, so what about if $X$ is not empty?
Well, here's another example:
$$X=\{1\}, \tau=\{\emptyset, X\}$$

OK OK, but there is no nontrivial closed set here, that's cheating!
OK then, $$X=\{1,2\}, \tau=\{\emptyset, \{1\}, X\}$$
A: Pick any $X$ and $a \in X$.
Define $Y \subset X$ to be open if and only i f$X= \emptyset$ or $a \in Y$. It follows that a set $Y$ is closed if and only if $Y=X$ or $a \notin Y$.
It is easy to show that this is a topology which has the required properties.
It is likely that there is no separable topology with these properties.
