What Is A Deterministic Algorithm?
Deterministic algorithm is the algorithm which, given a particular input will always produce the same output, with the underlying machine always passing through the same sequence of states. In other words, Deterministic algorithm will always come up with the same result given the same inputs.
Deterministic algorithms are by far the most studied and familiar kind of algorithm as well as one of the most practical, since they can be run on real machines efficiently. Formally, a deterministic algorithm computes a mathematics function; a function has a unique value for any input in its domain, and the algorithm is a process that produces this particular value as output.
Deterministic algorithms can be defined in terms of a state machine: a state describes what a machine is doing at a particular instant in time. State machines pass in a discrete manner from one state to another. Just after we enter the input, the machine is in its initial state or start state. If the machine is deterministic, this means that from this point onwards, its current state determines what its next state will be; its course through the set of states is predetermined. Note that a machine can be deterministic and still never stop or finish, and therefore fail to deliver a result.
Examples of particular abstract machines which are deterministic include the deterministic Turing machine and deterministic finite automaton.
What You Need To Know About Deterministic Algorithm
- Deterministic algorithm is the algorithm which, given a particular input will always produce the same output, with the underlying machine always passing through the same sequence of states.
- In deterministic algorithm the path of execution for algorithm is same in every execution.
- On the basis of execution and outcome in case of Deterministic algorithm, they are also classified as reliable algorithms as for a particular input instructions the machine will give always the same output.
- In Deterministic Algorithms execution, the target machine executes the same instruction and results same outcome which is not dependent on the way or process in which instruction get executed.
- As outcome is known and is consistent on different executions so deterministic algorithm takes polynomial time for their execution.
What Is A Non-deterministic Algorithm?
A nondeterministic algorithm is an algorithm that, even for same input, can exhibit different behaviors on different runs. In other words, it is an algorithm in which the result of every algorithm is not uniquely defined and result could be random.
An algorithm that solves a problem in nondeterministic polynomial time can run in polynomial time or exponential time depending on the choices it makes during. The nondeterministic algorithms are often used to find an approximation to a solution, when the exact solution would be too costly using a deterministic one.
A nondeterministic algorithm is different from its more familiar deterministic counterpart in its ability to arrive at outcomes using various routes. If a deterministic algorithm represents a single path from an input to an outcome, a nondeterministic algorithm represents a single path stemming into many paths, some of which may arrive at the same output and some of which may arrive at unique outputs.
What Makes An Algorithm Non-deterministic?
A variety of factors can cause an algorithm to behave in a way which is not deterministic, or non-deterministic:
- If it uses external state other than the input, such as user input, a global variable, a hardware timer value, a random value, or stored disk data.
- If it operates in a way that is timing-sensitive, for example if it has multiple processors writing to the same data at the same time. In this case, the precise order in which each processor writes its data will affect the result.
- If a hardware error causes its state to change in an unexpected way.
What You Need To Know About Non-deterministic Algorithm
- Non-deterministic algorithm is the algorithms in which the result of every algorithm is not uniquely defined and result could be random.
- In Non-Deterministic algorithm the path of execution is not same for algorithm in every execution and could take any random path for its execution.
- Non deterministic algorithms are classified as non-reliable algorithms for a particular input the machine will give different output on different executions.
- In Non-Deterministic Algorithms, the machine executing each operation is allowed to choose any one of these outcomes subjects to a determination condition to be defined later.
- As outcome is not known and is non-consistent on different executions so Non-Deterministic algorithm could not get executed in polynomial time.
Also Read: Difference Between NP Hard And NP Complete Problem
Difference Between Deterministic And Non-deterministic Algorithms In Tabular Form
BASIS OF COMPARISON | DETERMINISTIC ALGORITHM | NON-DETERMINISTIC ALGORITHM |
Description. | Deterministic algorithm is the algorithm which, given a particular input will always produce the same output, with the underlying machine always passing through the same sequence of states. | Non-deterministic algorithm is the algorithms in which the result of every algorithm is not uniquely defined and result could be random. |
Path Of Execution | In deterministic algorithm the path of execution for algorithm is same in every execution. | In Non-Deterministic algorithm the path of execution is not same for algorithm in every execution and could take any random path for its execution. |
Basis Of Comparison | On the basis of execution and outcome in case of Deterministic algorithm, they are also classified as reliable algorithms as for a particular input instructions the machine will give always the same output. | Non deterministic algorithms are classified as non-reliable algorithms for a particular input the machine will give different output on different executions. |
Operation | In Deterministic Algorithms execution, the target machine executes the same instruction and results same outcome which is not dependent on the way or process in which instruction get executed. | In Non-Deterministic Algorithms, the machine executing each operation is allowed to choose any one of these outcomes subjects to a determination condition to be defined later. |
Output | As outcome is known and is consistent on different executions so deterministic algorithm takes polynomial time for their execution. | As outcome is not known and is non-consistent on different executions so Non-Deterministic algorithm could not get executed in polynomial time. |