An electromagnet might have an inductance of 1 microhenry or it might have an inductance of 1 henry - we can't tell from your question. There is a formula that can tell you how rapidly the current rises when voltage is applied: -
\$V = L\dfrac{di}{dt}\$ 
So, if you apply 12 V and it is a 1 henry inductor the current will rise at 12 amps per second. If, you need a current of 5 A for your application, to reach that current from a 12 V supply takes five-twelfths of a second (417 ms).
Therefore switching / reversing at 20 Hz (charge-discharge time of 2 x 25ms) will only really give you a fraction of the current (about 0.3 A) of what you might really need. 
It's a bit worse than that - the hysteresis curve of iron (if that's what you are using) means you need to drive it a bit harder to reverse the magnetism to the same negative value as when first polarized in the positive direction.
To achieve this sort of performance (5 A in say 10 ms) means more a complex solution than just a simple H bridge and you need to think about this. You have also got to consider the energy "thrown away" as heat when the magnetic field is reversed. The energy stored in a 1 henry coil operating at 5 A is: -
\$ E = \dfrac{L I^2}{2}\$ = 12.5 joules and this is being turned into heat 20 times per second.
That's a power of 250 watts that needs to be got rid of.
OK I'm playing devil's advocate a bit and in all likelihood your electromagnet might only be 30 millihenry and use a current of 1 A. The point is, you haven't said and I can't guess but hopefully, if you read this you'll have some idea what problems you might face.