When the charges flow opposite from the positive electrode and negative electrode, the ionization of the electrolyte takes place during the process of electrolysis. This can be achieved by only dc supply.
When we use the ac supply, the polarity of electrodes changes and affects the electrolysis so it can not be used in electrolysis.