Spectral theory and quantum mechanics with an introduction to the algebraic formulation