Nepedia
Back to Discover
Fluent Reader
💻

Deterministic algorithm

technology Maturity 11-13 Next article →

A deterministic algorithm is a set of steps for a computer. It is a very common way for machines to work. If you give it the same starting information, it always gives the same result. This happens because the machine follows a set path every single time.

It is like a recipe that never changes. You use the same ingredients and get the same meal. This makes these algorithms very practical for real machines to use. They are well-studied because they are so reliable.

We can understand how this works by looking at a state machine. A state is what a machine is doing at one exact moment. The machine moves from one state to another in a specific way. First, the machine starts in an initial state. From that point, its current state tells it exactly what the next state will be.

The entire course is predetermined. This means the machine follows a path that is already decided. However, a machine can still fail to finish its task. It might run forever without ever delivering a result.

Some machines are built to be deterministic. These include the deterministic Turing machine. There is also the deterministic finite automaton.

These are abstract models used in computer science. They help experts study how logic works. Most programming languages try to keep things deterministic. This makes it easier for humans to understand the code. It also helps other programs work with the code correctly. Languages like Mercury and Haskell have special ways to manage these steps.

Sometimes, a program becomes non-deterministic. This means the result might change unexpectedly. This can happen if a person types something new. It can also happen if a timer goes off or a random value is used.

If a computer has many processors, they might write data at different times. This timing can change the final answer. Even a small error in the hardware can cause this. Experts use special tools to help deal with these hard jobs. They want to avoid things like deadlocks or race conditions.

There are times when we want a program to be unpredictable. A card shuffling program for a game like blackjack must be this way.

If the shuffle was predictable, players could guess the cards. A clever gambler might even cheat. The Software Security Group at Reliable Software Technologies found this was possible. They did this with a poker game from ASF Software, Inc. To stop this, computers use a hardware random number generator. This provides a source of randomness to keep the game a surprise.

427 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.