An algorithm is a well-defined sequential computational technique that accepts a value or a collection of values as input and produces the output(s) needed to solve a problem. Show Or we can say that an algorithm is said to be accurate if and only if it stops with the proper output for each input instance. Consider a box where no one can see what’s happening inside, we say a black box. We give input to the box and it gives us the output we need but the procedure that we might need to know behind the conversion of input to desired output is an ALGORITHM. An algorithm is independent of the language used. It tells the programmer the logic used to solve the problem. So, it is a logical step-by-step procedure that acts as a blueprint to programmers. Real-life examples that define the use of algorithms:
Types of Algorithms:
Why do we use algorithms?
In terms of designing a solution to an IT problem, computers are fast but not infinitely fast. The memory may be inexpensive but not free. So, computing time is therefore a bounded resource and so is the space in memory. So we should use these resources wisely and algorithms that are efficient in terms of time and space will help you do so. Creating an Algorithm:Since the algorithm is language-independent, we write the steps to demonstrate the logic behind the solution to be used for solving a problem. But before writing an algorithm, keep the following points in mind:
Example: algorithm to multiply 2 numbers and print the result:
Example 1: Write an algorithm to find the maximum of all the elements present in the array.
Example 2: Write an algorithm to find the average of 3 subjects.
Know about 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 :
Advantages of Algorithms
Disadvantages of Algorithms
|