How do you know that it is the alternator if the car starts then does not restart but later starts again?

Your problem may be due to a bad starter, not an alternator. An old, worn, or damaged starter will give the impression that there is not enough power to turn over the engine or give no responce at all as if the battery is dead. Then after it cools down it may be more willing to start. Give the starter a good tap with a tire iron while someone else turns the key when it won't start. Try your best to be syncronised with the ignition and tapping the starter. If it starts right up you got a bad starter. It may seem like a tap will get you by but it won't work for long.