In: Computer Science
What is an algorithm?
Why is it important in the field of computer programming?
Algorithm:
An algorithm is a step-by-step procedure that gives a solution to the problem.
For example:
Algorithm to convert a decimal number into a binary number:
Step 1: Start
Step 2: Declare variables binaryNumber, remainder, temp, and decimalNumber
Step 3: Read values decimalNumber
Step 4: while decimalNumber != 0
Step 4.1: remainder = decimalNumber MOD 2
Step 4.2: decimalNumber = decimalNumber / 2
Step 4.3: binaryNumber = binaryNumber + remainder * temp
Step 4.4: temp = temp * 10
Step 5: Display binaryNumber on the computer screen
Step 6: Stop
The above algorithm gives a solution to convert a decimal number to a binary number.
Why is it important?
It is very important in the field of computer programming. It is the initial step to solve a problem using the computer programming language. First of all, the algorithm is written if exists. If there is no algorithm to solve a problem then we can't write the source code for that problem.
The algorithm gives the step by step solution and the algorithm is converted into the pseudocode before start to coding. Finally, the source code is written to solve a problem.