Differences between randomized and non-deterministic algorithms

Overview

Randomized and non-deterministic algorithms are often misunderstood as the same most of the time. However, there are some important underlying differences between these algorithms.

Randomized algorithms

An algorithm that adds a degree of randomness to its logic to produce the final output. Along with the input, these algorithms take a source of random numbers (within a specified range) and these two together produce the output.

Thus, the output of such algorithms may vary for the same input when applied twice because the random number generated for the same input may be different the second time.

Due to this behavior, these algorithms are also called probabilistic algorithms.

The randomized algorithm flowchart

Non-deterministic algorithms

These algorithms are similar to randomized algorithms because they also produce different outputs for the same input. But in these algorithms, this is possible because they take different routes to solve the same problem, not by making any additions to the input.

The illustration of non-deterministic algorithms

Randomized

  • It adds external data to the given input.

  • It may not always produce the correct output.

  • It executes faster.

  • It’s used when random inputs have a better chance of producing the correct output (brute force process).

Non-deterministic

  • It doesn’t add anything to the given input.

  • It always produces the correct output.

  • It executes slower.

  • It’s used to find approximate solutions in case when exact solutions cannot be found.

Free Resources