# Algorithm in Computers

An algorithm in computers can be defined as step by step procedure that helps in solving simple and complex computational problems. We can also refer algorithm as a method used by the computer to determine the solution of a problem. And this algorithm behavior makes it different from the terms like process, technique, or method.

In this particular section, we will study the basic concept of algorithms. We will also look into how the programmers’ device and algorithm, how to validate it, how to analyze it, and also how to test it.

## Algorithm in Computers

1. ### What is an Algorithm?

An algorithm is a set of instructions that when followed accomplishes a particular task. However, every algorithm must satisfy certain criteria.

Input: Input is information externally supplied to the algorithm; the quantity of input supplied to the algorithm can range from zero to multiple.

Output: Output is a piece of information produced by the computer and an algorithm must produce output in at least one quantity.

Definiteness: Instructions of the algorithms must be precise and unambiguous.

Finiteness: For each test case the number of instructions in an algorithm must be finite which means if checkout for each test case in an algorithm the algorithm must end after a finite number of steps.

Effectiveness: Well, it is not enough that each instruction is definite; it must be very basic that even a person with paper and pencil can trace it down effectively.

### Characteristics of an Algorithm

Every algorithm includes a finite set of steps where each step may require one or more operations. The criteria for an algorithm to get executed are as follows:

• An algorithm must be supplied with zero or more inputs.
• An algorithm must produce at least one or more outputs.
• Each conducted operation must be definite which means it should precisely define what has to be done.
• An algorithm must get terminated after a finite number of steps.
• Each operation must be effective which means that it can be done by a person with pencil and paper in a finite amount of time.

### Example of Algorithm in Computers

Algorithms with definiteness and effectiveness are termed computational procedures. One of the most popular examples of algorithms or computational procedures is the operating system of our computer.

We know that the operating system (computational procedure) of any computer is designed to control the execution of jobs in such as way that even when no jobs are aligned for execution, the algorithm (OS) does not terminate it continues in a waiting state, until new job enters into the system.

To accomplish all the criteria we learned above, especially of definiteness we write algorithms using programming language. So we can say that a program written in any programming language is a legitimate expression of an algorithm.

### How to Devise Algorithms?

Devising or designing an algorithm is the art of programming. Programmers can try various designing techniques to yield a good algorithm. Learning various designing strategies helps programmers in designing new and useful algorithms.

### How to Validate Algorithms?

Once the programmers devise the algorithm the next step I to validate it against all possible legal inputs. Even at this stage, an algorithm can’t be stated as a program. Algorithm validation ensures the programmer that the algorithm will work accurately and independently of the issues concerning the programming language in which it will eventually be written.

Once the algorithm is validated in the second phase the programmers start writing the program. We also refer to this phase as a program proving or program verification phase. In this phase, programmers validate the program’s correctness by ensuring that each statement of the programming language precisely defines all the basic operations of the program.

### How to Analyze Algorithms?

When the algorithm executes it occupies the computer’s central processing unit i.e. CPU and even the memory that holds the program and data. Analyzing the algorithm helps the programmers to determine what computing time and storage the programmer requires. This phase is important and it requires mathematical skill. Analyzing the algorithm allows the programmers to make quantitative judgments of the value of one algorithm over the other. Also, it helps the programmers to determine whether the final software meets the efficiency constraints or not.

### How to Test a Program?

Testing of a program is done in two phases: debugging and profiling. To roll out debugging the testers execute the programs against the sample data set. While testing if any faulty result occurs, the programs are corrected. However, debugging can only determine the presence of errors but not their absence. So, several attempts are made to develop a correct program. In Profiling, we also refer to it as performance measurement, the correct program is executed on a valid data set in order to determine the time and space it requires for execution.