Electrolysis is an application of electrical energy to provoke a chemical reaction that does not spontaneously occur. This is an…