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!
Examples
- A delivery driver chooses the fastest route as traffic updates come in.
- You pick a movie to watch based on what you've already seen.
- A restaurant orders ingredients as customers arrive.
Ask a question
See also
- Explainer: What Is an Algorithm?
- What are computational limits?
- What are queues and stacks?
- What are computational methods?
- How Does 7 Branch and Bound Introduction Work?