I have attached here PPT of Basic Algorithm. By using the PPT, students will design any Algorithm. The PPT is mainly focus on "how to design efficient Algorithm".
3. Introduction
An algorithm is a sequence of
unambiguous instructions for solving a
problem, i.e., for obtaining a required
output for any legitimate input in a
finite amount of time.
Algorithm is a step-by-step procedure,
which defines a set of instructions to
be executed in a certain order to get
the desired output.
Algorithm is any well defined
computational procedure that takes
some value or set of values as input
and produces some value or set of
values as output.
4. Characteristics of an Algorithm
Unambiguous − Algorithm should be clear and unambiguous.
Each of its steps (or phases), and their inputs/outputs should be
clear and must lead to only one meaning.
Input − An algorithm should have 1 or more well-defined inputs.
Output − An algorithm should have 1 or more well-defined
outputs, and should match the desired output.
Finiteness − Algorithms must terminate after a finite number of
steps.
Feasibility − Should be feasible with the available resources.
Independent − An algorithm should have step-by-step
directions, which should be independent of any programming
code.
5. Algorithm development process
Our algorithm development process consists of five
major steps.
Step 1: Obtain a description of the problem.
Step 2: Analyze the problem.
Step 3: Develop a high-level algorithm.
Step 4: Refine the algorithm by adding more detail.
Step 5: Review the algorithm.
7. Design an algorithm to add two
numbers and display the result.
Step 1 − START
Step 2 − declare three integers a, b & c
Step 3 − define values of a & b
Step 4 − add values of a & b
Step 5 − store output of step 4 to c
Step 6 − print c
Step 7 − STOP
8. Find the largest number among
three different numbers
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a > b
If a > c
Display a is the largest number.
Else Display c is the largest number.
Else
If b > c
Display b is the largest number.
Else Display c is the greatest number.
Step 5: Stop
9. Factorial of a number entered by the
user.
Step 1: Start
Step 2: Declare variables n, factorial and i.
Step 3: Initialize variables
factorial ← 1
i ← 1
Step 4: Read value of n
Step 5: Repeat the steps until i = n
5.1: factorial ← factorial*i
5.2: i ← i+1
Step 6: Display factorial
Step 7: Stop
10. Check whether a number is a
prime number or not
Step 1: Start
Step 2: Declare variables n, i, flag.
Step 3: Initialize variables
flag ← 1
i ← 2
Step 4: Read n from the user.
Step 5: Repeat the steps until i=(n/2)
5.1 If remainder of n÷i equals 0
flag ← 0
Go to step 6
5.2 i ← i+1
Step 6: If flag = 0
Display n is not prime
else
Display n is prime
Step 7: Stop