Saturday 8 May 2021

Algorithm - Key features of algorithm

 According to the dictionary, algorithm can be represented by “A process or set of rules to be followed in calculation or other problem solving operations, especially a computer”.

Definition:

An algorithm is a finite set of instructions to accomplish a particular task in given problem.

Before writing a program for solving a problem it is better to write step by step process for solving it. This step by step process is called an algorithm.

Knuth (1968-1973) has given a list of five programming rules that are widely accepted as requirements

for an algorithm.

Finiteness: an algorithm must always terminate a finite number of steps.

Definiteness: Each step of an algorithm must be preciously defined the action to be carried out must be clear.

Input: Quantities which are given to it initially before the algorithm begins these inputs are taken from specified steps of objects.

Output: Quantities which have a specified relation to input.

Effectiveness: All of the operations to be performed in the algorithm must be sufficiently basic that they can in principle, by alone exactly and in a finite length of time by a man using paper and pencil.

Key features / various steps in algorithm development:

An algorithm has a finite number of steps may involve decision making and repetition. Broadly speaking an algorithm uses three control structures namely sequence, decision, and repetition.

Sequence:

Sequence means that each step of the algorithm is executed in the specified order.

Example: Algorithm to add two numbers.

Step1: start

Step2: read two numbers as a, b

Step3: set c=a+b;

Step4: print c

Step5: end  

Decision:

Decision statements are used when the execution of a process depends on the outcome of some conditions. A condition is any statement that may evaluate either to a true value or false value. A decision statement can be stated using if..else construct in the following manner.

If condition

Then statement 1

Else

The statement 2

Example: algorithm to check the equality of two numbers.

Step1: read two numbers as a, b

Step2: if a=b

Then print “two numbers are equal”

Else

Print “two numbers are not equal”

Step3: end

Repetition:

Repetition which involves executing one or more steps for a number of time, can be implemented using construction such as while, do-while, for loops.


0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top