Algorithms-
Linear Search and Binary Search
, Algorithm
• An “algorithm" is a formally defined procedure for performing some
calculation. It provides a blueprint to write a program to solve a
particular problem.
• It is considered to be an effective procedure for solving a problem in
finite number of steps. That is, a well-defined algorithm always
provides an answer and is guaranteed to terminate.
• Algorithms are mainly used to achieve software re-use. Once we
have an idea or a blueprint of a solution, we can implement it in any
high level language like C, C++, Java, so on and so forth.
, Characteristics of an Algorithm
The following are the characteristics of an algorithm:
• Input: An algorithm has some input values. We can pass 0 or some
input value to an algorithm.
• Output: We will get 1 or more output at the end of an algorithm.
• Unambiguity: An algorithm should be unambiguous which means
that the instructions in an algorithm should be clear and simple.
• Finiteness: An algorithm should have finiteness. Here, finiteness
means that the algorithm should contain a limited number of
instructions, i.e., the instructions should be countable.
• Effectiveness: An algorithm should be effective as each instruction
in an algorithm affects the overall process.
• Language independent: An algorithm must be
language-independent so that the instructions in an algorithm can
be implemented in any of the languages with the same output.
Linear Search and Binary Search
, Algorithm
• An “algorithm" is a formally defined procedure for performing some
calculation. It provides a blueprint to write a program to solve a
particular problem.
• It is considered to be an effective procedure for solving a problem in
finite number of steps. That is, a well-defined algorithm always
provides an answer and is guaranteed to terminate.
• Algorithms are mainly used to achieve software re-use. Once we
have an idea or a blueprint of a solution, we can implement it in any
high level language like C, C++, Java, so on and so forth.
, Characteristics of an Algorithm
The following are the characteristics of an algorithm:
• Input: An algorithm has some input values. We can pass 0 or some
input value to an algorithm.
• Output: We will get 1 or more output at the end of an algorithm.
• Unambiguity: An algorithm should be unambiguous which means
that the instructions in an algorithm should be clear and simple.
• Finiteness: An algorithm should have finiteness. Here, finiteness
means that the algorithm should contain a limited number of
instructions, i.e., the instructions should be countable.
• Effectiveness: An algorithm should be effective as each instruction
in an algorithm affects the overall process.
• Language independent: An algorithm must be
language-independent so that the instructions in an algorithm can
be implemented in any of the languages with the same output.