← Back to blogs

I've Been Thinking About Algorithms

September 21, 2026

i've been thinking about algorithms lately, and i thought i'd make a blog about it. in this one, i'm going to look at a few ideas behind how algorithms work, how they recommend stuff to you, how they keep up with your choices, and, of course, how i think about algorithms. this isn't really meant to be some highly technical blog either. you don't need to be a programmer or a tech enthusiast to understand the basic idea behind algorithms. understanding what happens deep beneath the surface is a different story, and i'm not really going there.

well then, let's begin. i'll do the writing, and you do the reading.

What is an Algorithm?

for starters, an algorithm is a finite set of well-defined steps or instructions designed to solve a problem or perform some computation. that's the formal way of putting it. you can read more about algorithms here .

in simple words, an algorithm is basically a step-by-step way of solving a problem or getting something done.

people often confuse algorithms with code. an algorithm is the actual idea or procedure for solving the problem, while code is how we express that idea in a programming language such as python or javascript so that a computer can execute it.

a simple analogy would be building a high-rise. before construction begins, you need a plan. the plan tells you what needs to happen and in what order. the actual construction is the part where that plan gets turned into something real. it's not a perfect analogy, but it gives you the general idea.

now let's see what an algorithm actually looks like.

How Does an Algorithm Even Look Like?

let's take an easy example. imagine i've just given you three different numbers: 14, 91, and 90. now suppose i ask you, "which is the largest number in the set?" you'd probably answer 91 almost immediately. there's nothing particularly difficult about it.

a computer, however, needs a proper procedure for doing that. it doesn't just look at the numbers and somehow decide that 91 feels larger. we have to give it a sequence of steps.

first, take the first number and temporarily assume it is the largest. then look at the next number. if that number is larger than the one we currently consider the largest, replace the old largest number with it. keep doing that until there are no numbers left. whatever number is left as the largest at the end is our answer: 91.

that's the algorithm. now we can write that same logic in a programming language. here are a few examples:

const numbers = [14, 91, 90];
let largest = numbers[0];

for (let i = 1; i < numbers.length; i++) {
    if (numbers[i] > largest) {
        largest = numbers[i];
    }
}

console.log(largest);
numbers = [14, 91, 90]
largest = numbers[0]

for i in range(1, len(numbers)):
    if numbers[i] > largest:
        largest = numbers[i]

print(largest)
#include <iostream>
using namespace std;

int main() {
    int numbers[] = {14, 91, 90};
    int largest = numbers[0];

    for (int i = 1; i < 3; i++) {
        if (numbers[i] > largest) {
            largest = numbers[i];
        }
    }

    cout << largest;
    return 0;
}

the code probably looks a little strange if you've never written code before, but notice what hasn't changed: the logic. the syntax changes depending on the language, but the underlying procedure is still the same.

finding the largest number is pretty straightforward. but algorithms can do much more than that. they can help decide which video appears on your homepage, which post gets shown to you, or which song gets recommended next.

and that's where things start getting a little more interesting.

So, How Does an Algorithm Recommend Something to Me?

now this is the part i've actually been waiting to write about.

before talking about how recommendation systems influence what you see, let's start with something you can actually observe yourself.

when you watch a video on youtube, or click on a post on x, you might notice that you start seeing more content that looks similar to what you interacted with. for example, suppose you watch a "top 10 funny cat moments" video on youtube. after that, you might start seeing more cat videos in your recommendations.

but here's the important part: the system doesn't literally know what you personally like. it has to make a prediction based on different signals. some of those signals can include:

What you click
What you watch
How long you watch something
What you skip
What you search for
What you like
What you subscribe or follow
What you repeatedly come back to

so the system gets information from your behaviour. it doesn't have to read your mind; your actions are already giving it clues.

take this simple scenario:

Video A → watched most of it
Video B → watched most of it
Video C → skipped after 5 seconds
Video D → watched most of it

now, which one gives the system less reason to think you're interested in it? probably video c. skipping one video obviously doesn't mean you'll never see anything like it again, but repeated behaviour like that can become a signal that you're not very interested in that type of content.

meanwhile, if you repeatedly watch and interact with videos similar to a, b, and d, the system has more reason to consider similar videos when deciding what to recommend to you. that's where engagement becomes part of the picture.

so, when another video appears that looks similar to the ones i've watched before, the system has some reason to think i might be interested in it.

but then another question comes up: what happens when my interests change?

How Does an Algorithm Keep Up With Me?

people's interests change. what i like today might not be what i like a month from now, so a recommendation system needs to account for new behaviour instead of treating my old preferences as permanent.

suppose i watch cat videos for 10 days. naturally, my feed starts filling up with cats. then, for whatever reason, i get bored of them and start watching dog videos instead.

my feed probably wouldn't transform into nothing but dogs immediately. but as i keep watching dog videos, searching for them, and interacting with them while doing less of that with cat videos, the newer behaviour can start influencing what gets recommended to me.

in other words, the system can gradually get a different picture of what i'm interested in. the older behaviour doesn't necessarily disappear instantly, but the newer behaviour gives it more information to work with.

and this is where algorithms get especially interesting to me. because now it's not just "the algorithm recommends something to me."

i'm giving the system information through my behaviour, and the system is using that information to shape what i see next.

now, if you're more interested in the technical side of things, here's a much more complicated example of what this kind of algorithmic balancing could look like. this is not how youtube or any other specific platform necessarily implements its recommendation system. it's just a simplified model showing how an algorithm could balance different signals when updating its idea of what i'm interested in.

const interests = {
    cats: 0.8,
    dogs: 0.2,
    gaming: 0.6
};

const interactions = [
    { topic: "dogs", watchRatio: 0.95, skipped: false, age: 1 },
    { topic: "dogs", watchRatio: 0.82, skipped: false, age: 2 },
    { topic: "cats", watchRatio: 0.15, skipped: true, age: 3 }
];

function updateInterest(profile, interaction) {
    const recency = 1 / (1 + interaction.age);
    const watchSignal = interaction.watchRatio;
    const skipPenalty = interaction.skipped ? -0.4 : 0;

    const signal =
        (watchSignal + skipPenalty) * recency;

    profile[interaction.topic] += signal * 0.5;

    profile[interaction.topic] =
        Math.max(
            0,
            Math.min(1, profile[interaction.topic])
        );
}

interactions.forEach(interaction => {
    updateInterest(interests, interaction);
});

console.log(interests);

again, this isn't a real recommendation system. it's just an example of algorithmic balancing. the algorithm isn't looking at one signal and making a decision from it. instead, several signals are combined and given different weights.

notice how watching most of a video increases the signal, skipping something gives it a penalty, and older behaviour has less influence because of the recency calculation. the final score is also kept between 0 and 1, so one interaction can't push the value infinitely high.

a real recommendation system can be vastly more complicated than this, with many more signals and models involved. but the basic idea is that the system is constantly balancing different pieces of information instead of simply saying "you watched a dog video, therefore you like dogs."

also, here is the c++ version of the same algorithm:

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

struct Interaction {
    string topic;
    double watchRatio;
    bool skipped;
    int age;
};

void updateInterest(
    vector<pair<string, double>>& profile,
    const Interaction& interaction
) {
    double recency =
        1.0 / (1.0 + interaction.age);

    double watchSignal =
        interaction.watchRatio;

    double skipPenalty =
        interaction.skipped ? -0.4 : 0.0;

    double signal =
        (watchSignal + skipPenalty) * recency;

    for (auto& interest : profile) {
        if (interest.first == interaction.topic) {

            interest.second +=
                signal * 0.5;

            interest.second =
                max(
                    0.0,
                    min(1.0, interest.second)
                );

            return;
        }
    }

    profile.push_back({
        interaction.topic,
        signal * 0.5
    });
}

int main() {

    vector<pair<string, double>> interests = {
        {"cats", 0.8},
        {"dogs", 0.2},
        {"gaming", 0.6}
    };

    vector<Interaction> interactions = {
        {"dogs", 0.95, false, 1},
        {"dogs", 0.82, false, 2},
        {"cats", 0.15, true, 3}
    };

    for (const auto& interaction : interactions) {
        updateInterest(interests, interaction);
    }

    for (const auto& interest : interests) {
        cout <<
            interest.first << ": "
            << interest.second
            << '\n';
    }

    return 0;
}

and python:

interests = {
    "cats": 0.8,
    "dogs": 0.2,
    "gaming": 0.6
}

interactions = [
    {
        "topic": "dogs",
        "watch_ratio": 0.95,
        "skipped": False,
        "age": 1
    },
    {
        "topic": "dogs",
        "watch_ratio": 0.82,
        "skipped": False,
        "age": 2
    },
    {
        "topic": "cats",
        "watch_ratio": 0.15,
        "skipped": True,
        "age": 3
    }
]


def update_interest(profile, interaction):
    recency = 1.0 / (1.0 + interaction["age"])
    watch_signal = interaction["watch_ratio"]
    skip_penalty = -0.4 if interaction["skipped"] else 0.0

    signal = (watch_signal + skip_penalty) * recency

    topic = interaction["topic"]

    if topic in profile:
        profile[topic] += signal * 0.5

        profile[topic] = max(
            0.0,
            min(1.0, profile[topic])
        )
    else:
        profile[topic] = signal * 0.5


for interaction in interactions:
    update_interest(interests, interaction)


for topic, score in interests.items():
    print(topic, ":", score)

Am I Influencing the Algorithm, or Is It Influencing Me?

earlier in the blog, i explained how algorithms recommend relevant stuff to you. you watch video A more than video B, so the system has more reason to recommend videos like A. so, you might think that i am the one who's influencing the algorithm.

but now imagine that those recommendations are the things i keep seeing. after a while, i might end up watching even more of those videos simply because those are the videos being put in front of me.

so... does this mean that i'm influencing the recommendations, but the recommendations are also influencing what i watch? i think, at least to some extent, yes.

it doesn't necessarily mean algorithms are literally controlling people. it's more like a feedback loop. this table might help you better understand it:

my behaviour
      ↓
recommendation system
      ↓
what i get shown
      ↓
what i interact with
      ↓
new information for the system
      ↓
new recommendations
      ↺

also, i'm aware that some recommendation-based platforms are built around continuous consumption, with features such as infinite scrolling and autoplay. but i think i wouldn't go too deeply into that here. maybe in a follow-up blog, we'll talk about recommendation systems and the way they can encourage people to keep watching, especially when it comes to social media.

Some thoughts

i think algorithms are useful tools. if you think about algorithms without recommendation systems, they are still a very useful part of computing. they can help break complex problems down into simpler steps, help complete tasks through logic, and generally give computers a procedure to follow.

but if you think about recommendation algorithms, then i think my thoughts are quite mixed. well, of course, there are useful sides and there are potential downsides. recommendation algorithms, especially on platforms built around scrolling through lots of content, can contribute to habits that are difficult to stop, and for some people, that can interfere with daily life.

a lot of kids these days use social media, and short-form videos are a big part of many social media platforms. those platforms often use recommendation systems to decide what appears next. you repeatedly skip a certain type of short video, for example, and that behaviour can become a signal that you're less interested in it. if you keep watching and interacting with videos about dogs, the system may have more reason to show you similar videos. that's basically how the recommendation part of the scrolling system works.

i think we have slightly drifted away from the main topic, but i still think this shows one of the potential downsides of recommendation systems.

the idea behind algorithmic recommendation sounds great on paper. you get to see relevant videos without having to search for everything yourself, while content you repeatedly ignore may become less relevant to future recommendations.

i think recommendation algorithms are a good idea in principle, but i also think they should have limitations. and maybe the best thing we can do as users is simply be aware of how they work.

looks like i have nothing more to write about algorithms... of course i have thousands of thoughts about algorithm but can't really write it now because of uncertainity.

well, see ya in the next blog, hope you got to learn some new stuff about Algorithms

( ̄▽ ̄)ノ