Design and Analysis of Algorithms
Step by step process to solve a particular problem is called an algorithm. Design and Analysis of Algorithm (DAA) are used to solve different types of problems. The program actually works according to the logic of the given DAA.
Algorithms can be complex or simple, which depends upon the nature of The problem you need to solve.
-
- Simple Algorithms: It can be done in a few steps i.e. algorithm of adding two numbers
- Complex Algorithms: It requires too many steps to solve the problem i.e. video compression algorithms
Actually, an algorithm considers an input, processes it, and provides an output.
Method to Write Algorithm
The algorithm can be written in any formal language or any programming language. Let’s consider an algorithm for interchanging the values of two variables.
A. Algorithm in formal language
In a formal language, it is very easy to write an algorithm, example is given below
-
- Read two numbers “a” and “b”.
- Consider a number, let “Temp”
- Put the value of “a” in “Temp”
- Put the value of “b” in “a”
- Put the value of temp in “b”
B. Algorithm In some Programming Languages
In a programming language, there is no need to mention data types for programming language.
Criteria of Algorithm Analysis
The criteria of the algorithm depend on various components which are discussed below
1. Time: More statements of the algorithm required more time consumption. The time value is calculated through the time function.
Important: Each Statement in the algorithm takes one unit of time. Here, we Don’t concern with machine analysis, we just considering at procedural (algorithm) level.
2. Space: More statements of the algorithm required more space consumption. Space value is calculated through the space function.
Important: Each Statement in the algorithm takes one-word space. Here, we Don’t concern with machine analysis, we just considering at procedural (algorithm) level.
3. Network Consumption: How much data is transferred through the algorithm?
4. Power Consumption: How much power is consumed while data transfer. It should be a minimum.
5. CPU registers: Consumption of CPU registers should be minimum for the ideal algorithm.
Characteristics of Algorithm
An algorithm contains various characteristics which represent the nature of the algorithm, some of them are given below
-
- Well-defined Input: The algorithm may consider 0 or more well-defined input values
- Well-defined Output: The algorithm must generate at-least one output value.
- Definiteness: Every statement of the algorithm should be clear (unambiguous). It can’t support complex numbers (iota or imaginary numbers). It works with real numbers (a combination of rational (2, 2.1, 4.1212.., 3.333333…., 2.242424…) and irrational numbers (2.12334455643…)).
- Finiteness: The number of statements should finite
- Effectiveness: Every statement should be purposeful.
- Language Independent: The Algorithm designed for a particular problem must be language independent
An example of the algorithm can apply to various fields of life i.e. chemistry experiments, cooking, etc.
Types of Algorithms
There are various types of algorithms; some of them are given under,
-
- Recursive Algorithm: It calls the same function again and again
- Searching Algorithm: It searches an element or groups of elements from a particular data structure.
- Sorting Algorithm: It arranges a group of data in an order i.e. increasing or decreasing
- Hashing Algorithm: It is similar to a searching algorithm but uses a key data value.
- Divide and Conquer Algorithm:It breaks a problem into sub-problems and then solves each sub-problem, after solving, merges the solutions of all sub-problems together to get the final solution. It contains the three major parts divide, solve and combine.
Advantages of Algorithms
Some crucial advantages of the algorithm are discussed below
-
- It is easy to understand.
- It is easy to build.
- It can be written in formal Language.
Disadvantages of Algorithms
Some important disadvantages of the algorithm are discussed below
-
- It is time-consuming because it takes too much time to write.
- An algorithm is not suitable for complex logic.
- It is difficult to show the Branching and Looping statements in Algorithms.
One Response
You have remarked very interesting points!
ps nice internet site.Money from blog