briefly explain the algorithm