In 2015, Guth proved that if S is a collection of n g-dimensional semi-algebraic sets in ℝd and if D ≥ 1 is an integer, then there is a d-variate polynomial P of degree at most D so that each connected component of ℝd \ Z(P) intersects O(n/Dd−g) sets from S. Such a polynomial is called a generalized partitioning polynomial. We present a randomized algorithm that computes such polynomials efficiently – the expected running time of our algorithm is linear in |S|. Our approach exploits the technique of quantifier elimination combined with that of ε-samples. We present four applications of our result. The first is a data structure for answering point-enclosure queries among a family of semi-algebraic sets in Rd in O(log n) time, with storage complexity and expected preprocessing time of O(nd+ε). The second is a data structure for answering range search queries with semi-algebraic ranges in O(log n) time, with O(nt+ε) storage and expected preprocessing time, where t > 0 is an integer that depends on d and the description complexity of the ranges. The third is a data structure for answering vertical ray-shooting queries among semi-algebraic sets in ℝd in O(log2 n) time, with O(nd+ε) storage and expected preprocessing time. The fourth is an efficient algorithm for cutting algebraic planar curves into pseudo-segments.