Why does this circuit work with no ground?

If you are applying 5v to the circuit then the pins themselves provide the ground when they go LOW.