What is a consensus algorithm?

Hello. What is a consensus algorithm? What are its types and how do they differ? Could someone explain it to me step by step? Thanks