Quantum theory is thought to explain the periodic law which underlies the periodic table (PT); however, the lengths of the periods remain unexplained. Also, this explanation depends on two empirical rules, namely Madelung's n+l rule and Hund's rule. Furthermore, even Madelung's rule fails to explain the ground state configuration for many elements. Toward achieving an explanation of the periodic table, the Hartree-Fock (HF) method has been applied in this paper to calculate energies of various possible configurations of transition metals in the fourth and fifth periods. These calculations for Cr, Cu and Ni do not agree with the spectroscopically observed ground state configurations. We further calculated the nonrelativistic and relativistic energies of the various possible configurations of second row transition metals such as niobium, palladium, molybdenum and silver for which Madelung's rule predicts the wrong ground state configuration. In contrast to Cr and Cu, the observed ground state configuration of these elements is found to be associated with the lowest energy by HF calculations.