Visit for more Learning Resources Chapter 1 Visit for more Learning Resources
An Algorithm is a finite set of instructions that if followed accomplishes a particular task.
Finiteness Definiteness Effectiveness Input Output
Name of the algorithm and an introductory Comment. Steps Comments Assignments Statements Exit Statement Variable Name Operators Input and Output Statements Flow Chart
Name of the algorithm and an introductory Comment. LINEAR_SEARCH(A,N,KEY) [ ALGORITHM TO PERFORM LINEAR SEARCH]
Steps 1. …….. 2…….. 3…….
COMMENTS [ ] Comments are written in brackets
Assignments Statements Dot and equal to O= Var o= 45
Exit Statement Exit / finished / end
Variable Name In capital Eg :- VAR1 VAR2
OPERATORS LOGICAL OPERATOR (AND &&,OR ||,NOT !) RELATIONAL OPERATOR (<,>,<=,>=) ARTHEMATIC OPERATOR (+,-,*,/)
Input and Output Statements Read : VAR (SCANF() ) ---- ACCEPT DATA FROM USER Write Message (Printf() --- print data on the screen
Flow Chart
Brute Force Divide and Conquer Dynamic Programming Greedy Algorithm
Space Complexity It is the amount of memory required for that particular algorithm. Time Complexity Deals with the computing time.
void main() { int a; float b,c; c = a+b; printf(“Result = %d”,c) } Space Required = 2+4+4 = 10 bytes.
void main() { int a; --------------- 1 float b,c; --------------- 1 c = a+b; --------------- 1 printf(“Result = %d”,c); ---- 1 } Total Frequency count = 1+1+1+1 = 4
void main() { int a,n; --------------- 1 float b,c; --------------- 1 n = 3 for(i=0;i<=n;i++) --------- n c = a+b+i; --------------- n printf(“Result = %d”,c); ---- n } Total Frequency count = 1+1+n+n+n = 11
For more detail contact us Provides asympostotic upper bound for a given functions Max (O(1),O(n),O(n+1),O(n^2) For more detail contact us