There is no single algorithm. Each platform runs several systems at once, for the main feed, stories, short video, search and recommendations, and each weighs signals differently and changes often. Platforms publish general principles, but never the full recipe.
What stays consistent is the logic underneath. The systems learn from behaviour: who watches to the end, who comments, shares, saves or follows, and who scrolls past. They also work out what a post is about, from its caption, on-screen text, sound and hashtags, so they can show it to people likely to care.