Cohomological dimension of certain algebraic varieties