How does the algorithm work?