What are online algorithms?

Online algorithms are like magic helpers that make decisions as they go along, without knowing what’s coming next.

Imagine you're at a cookie jar, and every time you take a cookie, you don’t know if there will be more cookies or not. You just pick one, maybe the biggest one, or the first one you see. That's like an online algorithm: it makes choices as they come, without knowing everything in advance.

How It Works

Let’s say you're trying to share candies with your friends. Each time a friend comes up, you give them a candy, but you don’t know how many more friends are coming. You might decide to give bigger candies first or save the best ones for later. That's what online algorithms do: they choose the best option right when it happens, without waiting for all the information.

Why It Matters

Online algorithms are used in real life, too, like when a robot helps you pick out your favorite toy from a shelf, or when your phone decides which app to open first. They're always working on the go, just like you at the cookie jar!

Take the quiz →

Examples

  1. A delivery driver chooses the fastest route as traffic updates come in.
  2. You pick a movie to watch based on what you've already seen.
  3. A restaurant orders ingredients as customers arrive.

Ask a question

See also

Discussion

Recent activity