Let R be a real closed field and C the algebraic closure of R. We give an algorithm for computing a semi-algebraic basis for the first homology group, H1(S, F), with coefficients in a field F, of any given semi-algebraic set S ⊂ R k defined by a closed formula. The complexity of the algorithm is bounded singly exponentially. More precisely, if the given quantifier-free formula involves s polynomials whose degrees are bounded by d, the complexity of the algorithm is bounded by (sd. This algorithm generalizes well known algorithms having singly exponential complexity for computing a semi-algebraic basis of the zero-th homology group of semi-algebraic sets, which is equivalent to the problem of computing a set of points meeting every semi-algebraically connected component of the given semi-algebraic set at a unique point. It is not known how to compute such a basis for the higher homology groups with singly exponential complexity.As an intermediate step in our algorithm we construct a semi-algebraic subset Γ of the given semi-algebraic set S, such that Hq(S, Γ) = 0 for q = 0, 1. We relate this construction to a basic theorem in complex algebraic geometry stating that for any affine variety X of dimension n, there exists Zariski closed subsetswith dimC Z (i) ≤ i, and Hq(X, Z (i) ) = 0 for 0 ≤ q ≤ i. We conjecture a quantitative version of this result in the semi-algebraic category, with X and Z (i) replaced by closed semi-algebraic sets. We make initial progress on this conjecture by proving the existence of Z (0) and Z (1) with complexity bounded singly exponentially (previously, such an algorithm was known only for constructing Z0).