Step-by-step explanation:
Ionization energy is defined as the energy required to remove most loosely bound electron from a gaseous atom or ion.
Larger is the size of atom less energy will be necessary to remove the valence electron because force of attraction will be less between the nucleus and outermost electron.
Hence, it is easy to remove the outermost electron.
Whereas smaller is the size of atom great amount of energy will be required by it to remove the loosely bound electron.
So, when we move down a group there will be increase in size of atoms. Hence, ionization energy decreases.
On the other hand, when we move across a period then there occurs decrease in size of atoms. Hence, ionization energy increases.
As, magnesium is smaller is size than sodium and both of then are same period elements.
Thus, we can conclude that magnesium (Mg) atom has the higher ionization energy.