Algorithm

Shape Image One

ALGORITHM

advanced divider

ALGORITHM:

An algorithm is a procedure or formula for solving a problem. It can be defined as the set of
well-defined step by step instructions to solve a program. In computer science an algorithm
usually means a small procedure that solves a specific problem designs; algorithms are
widely used throughout all areas of IT. There are two common methods to represent
algorithm designs; pseudocode and flowcharts.

ROLE OF ALGORITHM IN PROBLEM SOLVING:

Algorithms give us the most ideal option of accomplishing a task in problem solving.
Algorithms are used to find the best possible way of solving a problem. In doing so they
improve the efficiency of a program. With the best algorithm, a computer program will be able to produce very accurate results. An algorithm can be used to improve the speed at which a program executes.

QUALITIES OF A GOOD ALGORITHM:

⦁ Inputs and outputs should be defined exactly.
⦁ Every step in an algorithm must be clear, precise and unambiguous.
⦁ It should be effective among many different ways to solve a problem.
⦁ It shouldn’t have computer code. Instead, the algorithm must be written in such a way that, it can be used in similar programming languages.

ALGORITHM EXAMPLES:

ALGORITHM 1: MAKING A CUP OF TEA

Step 1: Start.
Step 3: Fill the kettle with water.
Step 4: Boil the water in the kettle.
Step 5: Pour some of the boiled water into the cup.
Step 6: Add milk to the cup.
Step 7: Add sugar to the cup.
Step 8: Stir the tea.
Step 9: Drink the tea.
Step 10: Stop

ALGORITHM 2: SUBTRACTION OF TWO NUMBERS

Step 1: Start
Step 2: Declare variables n1, n2 & sub
Step 3: Read values n1 & n2
Step 4: Subtract n1 & n2 and assign the result to sub
sub-n1-n2
Step 5: Display sub
Step 6: Stop

ALGORITHM3: ADDITION OF TWO NUMBERS

Step 1: Start
Step 2: Declare variables n1, n2 & sum
Step 3: Read values n1 & n2
Step 4: Add n1 & n2 and assign the result to
sum = n1+n2
Step 5: Display sum
Step 6: Stop

ALGORITHM 4: MULTIPLICATION OF TWO NUMBERS

Step 1: Start
Step 2: Declare variables n1, n2 & mul
Step 3: Read values n1 & n2
Step 4: Multiply n1 & n2 and assign the result to mul
mul = n1* n2
Step 5: Display mul
Step 6: Stop

ALGORITHM 5: AREA OF CIRCLE

Step 1: Start
Step 2: Declare variable r and area
Step 3: Read value of r
Step 4: Apply formula {Area = (3.142) * r* r}
area (3.142) *r*r
Step 5: Display area
Step 6: Stop

Quiz

advanced divider