A distributed consensus ensures a consensus of data among nodes in a distributed system or reaches an agreement on a proposal.
A consensus algorithm may be defined as the mechanism through which a blockchain network reach consensus. Public (decentralized) blockchains are built as distributed systems and, since they do not rely on a central authority, the distributed nodes need to agree on the validity of transactions. This is where consensus algorithms come into play. They assure that the protocol rules are being followed and guarantee that all transactions occur in a trustless way, so the coins are only able to be spent once.