Imagine you are playing with your toys, and your mom is watching you. She wants to keep track of how many toys you play with, but she doesn't want to miss any of them. So, every time you start playing with a new toy, she makes a note of it.
Now, let's say you have too many toys to play with at once, and you start putting some away. Your mom doesn't want to keep track of the toys you put away, she only wants to keep track of the toys you are currently playing with. So, she decides to only write down the number of toys you are currently playing with, instead of every toy you have played with so far.
This is similar to an online algorithm. An online algorithm is like your mom, but for a computer. It's a way for a computer to make decisions and keep track of things, without having all the information at once.
For example, let's say you have a game that generates a lot of random numbers, and you want to find the highest number. In a regular (offline) algorithm, you would generate all the numbers first, then look through them to find the highest one. But in an online algorithm, you would generate the numbers one at a time and keep track of the highest number you've seen so far.
This is helpful because it saves time and memory. Instead of having to store all the numbers first, you only need to keep track of one number at a time. And, if you are working with a large amount of data, it may not even be possible to store it all at once in memory.
So, an online algorithm is like a smart parent who can keep track of what you are doing, even if they don't know everything that's going to happen ahead of time.