Explore 100's Of Free Video Tutorials

Keep Learning, Keep Coding & Keep Sharing

Introduction to Algorithms


Introduction to Algorithms :

Algorithm: (Natural language statements[Instructions])
Algorithm is a step by step procedure to solve a specific problem,
contains set of precise and well defined instructions /commands

The term “algorithm” has come from the name of a Persian mathematician Abu Ja’far Muhammad Ibn Musaa Alkhwarizmi. From the term “Alkhwarizmi” the term “Algorism” and then the term “Algorithm” has been coined. Alkhwarizmi has given a great contribution to various fields like mathematics, astrology, geography, computer science etc.

Algorithm: Find the sum of two numbers
Step 1: Start [Start of algorithm]
Step 2: Declare a variable num1
Step 3: Declare a variable num2
Step 4: Declare a variable sum
Step 5: Assign the value 10 to variable num1
Step 6: Assign the value 10 to variable num2
Step 7: Add value in num1 and value in num2, and assign the result to variable sum
Step 8: Print the value in variable sum
Step 9: Stop [End of algorithm]

Characteristics of a good algorithm:
Input: Accepts zero or more inputs
Definite: Steps are precisely defined, and unambiguous
Output: Produces one or more correct outputs (Correct)
Finite: Algorithm should terminate after finite steps
Efficient: memory and time efficient

Benefits of algorithm:
As algorithms contain natural language statements, algorithms are easy to write, understand
Algorithm can be converted to a computer program in any programming language,
Hence algorithms are programming language independent

Algorithms are pre-plans, they help us to:
debug, check for correctness and efficiency before writing the program itself
Algorithms can be easily translated to pseudo code, to flowcharts then to a program