Algorithms for Sparsity-Constrained Optimization