An algorithm is a set of mathematical rules that describe how a collection of data should behave. Algorithms in social media help in maintaining order and ranking search results and adverts. For instance, an algorithm on Facebook determines the order in which sites and information are shown.