Computer >> Computer tutorials >  >> Programming >> Programming

Difference between Deterministic and Non-deterministic Algorithms


In the context of programming, an Algorithm is a set of well-defined instructions in sequence to perform a particular task and achieve the desired output. Here we say set of defined instructions which means that somewhere user knows the outcome of those instructions if they get executed in the expected manner.

On the basis of the knowledge about outcome of the instructions, there are two types of algorithms namely − Deterministic and Non-deterministic Algorithms. Following are the main differences between both of the algorithms −

Sr. No.KeyDeterministic AlgorithmNon-deterministic Algorithm
1DefinitionThe algorithms in which the result of every algorithm is uniquely defined are known as the Deterministic Algorithm. In other words, we can say that the deterministic algorithm is the algorithm that performs fixed number of steps and always get finished with an accept or reject state with the same result.
On other hand, the algorithms in which the result of every algorithm is not uniquely defined and result could be random are known as the Non-Deterministic Algorithm.
2ExecutionIn 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.On other hand in case of 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.
3TypeOn 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.On other hand Non deterministic algorithm are classified as non-reliable algorithms for a particular input the machine will give different output on different executions.
4Execution TimeAs outcome is known and is consistent on different executions so Deterministic algorithm takes polynomial time for their execution.On other hand as outcome is not known and is non-consistent on different executions so Non-Deterministic algorithm could not get executed in polynomial time.
5Execution pathIn deterministic algorithm the path of execution for algorithm is same in every execution.On other hand in case of Non-Deterministic algorithm the path of execution is not same for algorithm in every execution and could take any random path for its execution.