The algorithm is intended to allow the user to agree on the status of the blockchain. There are two strategies for achieving consensus on a hierarchy.
Proof-of-Work (PoW): It only receives rewards for the work you invest in the system. This step requires computing power in solving puzzles. For every solution, a new block is created. So, the more work you put in, the higher the reward.
Proof-of-Stakes (PoS): This is a reward for what you bet. This requires you to keep your coins affected for some time to prove you are a related party. The more money you have, the more reward you have.