DSA Algorithm
DSA Algorithm
Deterministic algorithm:
• In a deterministic algorithm, for a given particular input, the computer will
always produce the same output going through the same states and follow a
predictable sequence of steps to arrive at that output
• Can solve the problem in polynomial time.
• Can determine the next step of execution.
• The 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.
• 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 deterministic algorithm the path of execution for algorithm is same in
every execution.
• As outcome is known and is consistent on different executions so
Deterministic algorithm takes polynomial time for their 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.
• Example bubble sort
• Predictable processing
• No randomness.
• Consistance result.
non-deterministic algorithm
• non-deterministic algorithm, for the same input, the compiler may
produce different output in different runs.
• In fact, non-deterministic algorithms can’t solve the problem in
polynomial time and can’t determine what is the next step.
• The non-deterministic algorithms can show different behaviors for
the same input on different execution and there is a degree of
randomness to it.
• 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
• the machine executing each operation is allowed to choose any one of these
outcomes subjects to a determination condition to be defined later.
• 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.
• outcome is not known and is non-consistent on different executions so Non-
Deterministic algorithm could not get executed in polynomial time.
• the path of execution is not same for algorithm in every execution and could
take any random path for its execution.
Deterministic Algorithms Non-deterministic Algorithms
It has a single outcome. It has multiple outcomes.
• The θn is the formal way to express both the lower bound and upper
bound of an algorithm's running time. It is represented as following.
• It represents the upper and the lower bound of the running time of an
algorithm, it is used for analyzing the average-case complexity of an
algorithm.
• Let g and f be the function from the set of natural numbers to itself.
The function f is said to be Θ(g), if there are constants c1, c2 > 0 and a
natural number n0 such that c1* g(n) ≤ f(n) ≤ c2 * g(n) for all n ≥ n0.
• Θ (g(n)) = {f(n): there exist positive constants c1, c2 and n0 such that 0
≤ c1 * g(n) ≤ f(n) ≤ c2 * g(n) for all n ≥ n0}
3. Omega Notation (Ω-Notation):
• Omega notation represents the lower bound of the
running time of an algorithm. Thus, it provides the best
case complexity of an algorithm.
• Omega notation represents the lower bound of the running time of
an algorithm. Thus, it provides the best case complexity of an
algorithm.
• The execution time serves as a both lower bound on the algorithm’s
time complexity.
• It is defined as the condition that allows an algorithm to complete
statement execution in the shortest amount of time.
• Let g and f be the function from the set of natural numbers to itself.
The function f is said to be Ω(g), if there is a constant c > 0 and a
natural number n0 such that c*g(n) ≤ f(n) for all n ≥ n0
Thank You..