Definition of Algorithm
Definition of Algorithm
Definition of Algorithm
The process of algorithm development generally involves many steps. The general steps
involved in algorithm development are as follows:
1. Problem Definition
2. Problem Analysis
3. Algorithm Design
4. Flowchart
5. Implementation
6. Testing
7. Documentation
Types of Algorithms:
Sorting algorithms: Bubble Sort, insertion sort, and many more. These
algorithms are used to sort the data in a particular format.
Searching algorithms: Linear search, binary search, etc. These algorithms are
used in finding a value or record that the user demands.
Characteristics of an Algorithm?
As one would not follow any written instructions to cook the recipe, but only the
standard one. Similarly, not all written instructions for programming are an
algorithm. For some instructions to be an algorithm, it must have the following
characteristics:
Well-Defined Outputs: The algorithm must clearly define what output will be
yielded and it should be well-defined as well. It should produce at least 1 output.
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.
Input: An algorithm has zero or more inputs. Each that contains a fundamental
operator must accept zero or more inputs.
Finiteness: An algorithm must terminate after a finite number of steps in all test
cases. Every instruction which contains a fundamental operator must be
terminated within a finite amount of time. Infinite loops or recursive functions
without base conditions do not possess finiteness.
Advantages of Algorithms
1. Easy to understand: Since it is a stepwise representation of a solution to a
given problem, it is easy to understand.
Disadvantages of Algorithms
Creating efficient algorithms is time-consuming and requires good logical skills.
Seen someone cooking your favorite food for you? Is the recipe necessary for
it? Yes, it is necessary as a recipe is a sequential procedure that turns a raw
potato into a chilly potato. This is what an algorithm is: following a procedure to
get the desired output. Is the sequence necessary to be followed? Yes, the
sequence is the most important thing that has to be followed to get what we want.
Algorithm Complexity:
An algorithm is analyzed using Time Complexity and Space Complexity. Writing an
efficient algorithm help to consume the minimum amount of time for processing the
logic. For algorithm A, it is judged on the basis of two parameters for an input of size
n any number of elements. :
Time Complexity: Time taken by the algorithm to solve the problem. It is
measured by calculating the iteration of loops, number of comparisons etc.
Space Complexity: Space taken by the algorithm to solve the problem. It
includes space used by necessary input variables and any extra space
(excluding the space taken by inputs) that is used by the algorithm. For
example, if we use a hash table (a kind of data structure), we need an array to
store values so this is an extra space occupied, hence will count towards the
space complexity of the algorithm. This extra space is known as Auxiliary
Space
3. In the algorithm, plain text is used. In the flowchart, symbols/shapes are used.
Pseudo code:
Pseudo code is an informal way of programming description that does not require any
strict programming language syntax or underlying technology considerations. It is used
for creating an outline or a rough draft of a program.