Algebraic characterization of some disconnected spaces