Quantum Algorithms for Machine Learning and Optimization