Why are the electrodes of a linac connected to an alternating voltage? Within an electrode the electron moves with a constant speed, and once it is outside of the electrode it accelerates uniformly, because of the voltage. But why is there a need for it to be alternating?
Linacs come in several types, but the kind you are talking about are segmented devices.
The device is divided into multiple regions, each developing a strong electric field, but to avoid needed million volt potentials (as in a van de Graff accelerator) the regions have alternating fields at any given moment.
Then you arrange for a bunch of charged particles to enter the device at a time when the field has the polarity that will accelerator those particles. However, the particles are moving, so if you just left the field that way the beam would enter the next region (where the field points the other way) and lose all the energy the gained in the first region. Instead, you swap the field as the particles move between regions. That way they pick up more energy in the second region. Then you swap feilds again before they move into the third region and they get another boost and so on.
All of this happens very fast, of course, so in modern devices the power is provided at radio frequencies. Indeed the super conducting klystrons that are all the rage are resonant cavity devices working in the radio band.