  In this article, we first prove a general theorem which asserts that every
quasi-component of a quasi-spectral space is connected. As an application, it
is shown that every connected component of a quasi-compact quasi-separated
scheme is the intersection of all clopen (both open and closed) subsets
containing a point. In particular, the connected components of an affine scheme
Spec$(R)$ are precisely of the form $V(J)$ where $J$ is a proper ideal of the
ring $R$ generated by a set of idempotent elements such that $R/J$ has no
nontrivial idempotents. The above result also contributes to the following open
problem: Is there a way to describe the connected components of the projective
space $\mathbb{P}_{A}^{n}={\rm Proj}(A[x_{0},\ldots,x_{n}])$ in a precise form
(similar the affine case)? Next, we characterize the finiteness of the number
of connected components of an arbitrary (quasi-compact) topological space in
terms of purely algebraic conditions. In particular, a topological space $X$
has finitely many connected components if and only if $X$ has finitely many
clopens. In this case, $|{\rm Clop}(X)|=2^n$ where $n$ is the number of
connected components of $X$. More surprisingly, we prove that a quasi-compact
space $X$ has finitely many connected components, i.e.
$\kappa=|\pi_{0}(X)|<\infty$ if and only if $|{\rm Clop}(X)|=2^\kappa$. In the
same vein, we prove that a commutative ring $R$ has finitely many idempotents
if and only if there exists a decomposition
$R\simeq\prod\limits_{k=1}^{n}R/(1-e_{k})$ with each $e_k$ is a primitive
idempotent of $R$.
