Answer
a) Magnesium: [Ne]$3s^2$
b) Oxygen: [He]$2s^2$$2p^4$
c) Sulfur: [Ne]$3s^2$$3p^4$
d) Nitrogen: [He]$2s^2$$2p^3$
Work Step by Step
Abbreviated electron configurations begin with the Noble gas from Group 8A from the period BEFORE the one your element is in and work outward from there.
a) Magnesium: Period 3, Group 2A. Begins with [Ne] because Neon is the Noble gas in period 2. The electron configuration after [Ne] then beings with the 3rd s sublevel until all the electrons are accounted for. Thus, Mg, with 12 electrons, begins with [Ne] (10 electrons), the $3s^2$, to equal 12 total, represented like so: [Ne]$3s^2$.
b) Oxygen: 8 electrons. Period 2, Group 6A, so n=2, with 6 valence electrons. Noble gas for period 1 is Helium (He), so the abbreviated electron configuration is [He]$2s^2$$2p^4$.
c) Sulfur: 16 electrons. Period 3, Group 6A, n=3, with 6 valence electrons. The noble gas for period 2 is Neon (Ne), so the abbreviated electron configuration is [Ne]$3s^2$$3p^4$.
d) Nitrogen: 7 electrons. Period 2, Group 5A, n=2, with 5 valence electrons. The noble gas for period 1 is Helium (He), so the abbreviated electron configuration is [He]$2s^2$$2p^3$.