- An algorithm is a finite lists of instructions in sequence to solve the computation problems.
- An algorithm is a step by step of finite number of process to solve the problems.You can write the algorithms in any language which is understandable to the persons (programmers)
- In Real life,an algorithm is a recipe for any cooking dish.
Characteristics of Algorithms:-
- Input:-An algorithm should have one or more inputs.
- Output:-An algorithm must have at least one output.
- Definiteness:- Every statement in any algorithm should be definiteness.It means.Every statement in algorithm should have unambiguous.Every statement should have clear and there should not be more than one way to interprate the single statement in given algorithm.
- Finiteness:-An algorithm should have a finite number of steps(instructions) to solve the problems and get a valid output.
- Effectiveness:-An algorithm should have effectiveness and produce well defined output of any programs. Effectiveness means, an algorithms should have good method which produce effective output with less time and less storage capacity.
Design of Algorithms:-There are different ways to represent an algorithm as given below:-
- Natural Language:- We can write the algorithms in any natural language which is understandable to the persons..Natural language is a human language. eg. English, Hindi ,French ,Chinese etc.Natural languages are not a effective language.It is a ambiguous language.It doesn't give a precise idea .
- Pseudo code:-Pseudo codes gives precise idea for any algorithms.It is unambiguous in nature.There are many control statements like for ,if,while,do,etc.It gives iterative codes that makes an algorithm effectiveness.We are generally use this language to write the precise codes.
- Flow chart:-This another way to write an algorithm to solve step by step problems in graphical manner.We will learn this technique in details in our coming lectures.
Different between Algorithms and programs:-
There are some difference between algorithms and programs as given below:-
- Start
- Read array elements
- Scan n elements in array A
- Declare a sum variable
- Assign zero value in sum variable
- Add all array elements using for loop
- Display the sum
- stop
#Write a Algorithm in Pseudo code:-
- start
- Read Array A
- sum<--0
- for <--1 to n do
- sum<--sum A[i]
- display sum
- stop
#Write a Algorithm in Flow Chart:-
Python Programs to add an Array elements:-
#intialize the array
A=[1,2,3,5,8,9,11,13,15,17]
sum=0
for i in range(0,len(A)):
sum=sum+A[i]
print("Sum of all array elements is=",sum)
Output of Above Python Codes:-Sum of all array elements is= 84
For More...
Watch Lecture 18 complete Video
nice
ReplyDelete