Using algorithms to simulate a traffic light system…