Programming Assignment
Programming Assignment
1.1 Algorithm
What is ALGORITHM?
A well-defined algorithm is a sequential computing method that provides the
output necessary to solve a problem by accepting a value or set of values as input.
Another option is to state that an algorithm is considered accurate if and only if it
terminates with the right output for each input instance. Take into consideration a
"black box," or a container where nothing can be seen inside. The box accepts our
input and produces the desired output for us, but the process by which the input is
changed into the intended output is an ALGORITHM, which we may need to
understand. The language being used has no bearing on an algorithm. It reveals to
the programmer the methodology applied to resolve the issue.
Every time you use your phone, computer, laptop, or calculator you are using
Algorithms. Similarly, algorithms help to do a task in programming to get the
expected output.
Clear and Unambiguous: The algorithm should be clear and unambiguous. Each
of its steps should be clear in all aspects and must lead to only one meaning.
Well-Defined Inputs: If an algorithm says to take inputs, it should be well-defined
inputs.
Well-Defined Outputs: The algorithm must clearly define what output will be
yielded and it should be well-defined as well.
Finite-ness: The algorithm must be finite, i.e. it should terminate after a finite
time.
Feasible: The algorithm must be simple, generic, and practical, such that it can be
executed with the available resources. It must not contain some future technology
or anything.
Language Independent: The Algorithm designed must be language-independent, it
must be just plain instructions that can be implemented in any language, and yet
the output will be the same, as expected.
Linear Search
Linear search, often known as sequential search, is the most basic search technique. In
this type of search, you go through the entire list and try to fetch a match for a single
element. If you find a match, then the address of the matching target element is returned.