3 Intro Algo
3 Intro Algo
The study materials/presentations used in this course are solely meant for academic
purposes and collected from different available course materials, slides, book, etc.
Disclaimer
• The word algorithm has come from the name of famous Persian
mathematician Abu Ja’far Mohammed ibn-i Musa al Khowarizmi
• Algorithm – Algorithm is step by step instruction followed to solve a
computational problem. It delineates the essence of a computational
procedure.
• Program- An implementation of an algorithm with the help of a
programming language.
• Data Structure – Organization of data required for solving the problem.
Data needs to be organised properly such that it can be effectively
used during the program execution
Example- an array or a linked list
Data structures and Algorithms are inseparable!
CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd) 4
Introduction
• Many possible input instances may exist that satisfies the input
specification
• Example- A sorted list of integers of finite length
34, 89, 100, 2345, 7892
5
Question
Out of all these possible correct algorithms, which one to choose?
• Representation of Algorithm
Flowchart – Graphical representation, works well for small & simple
algorithms
Pseudocode – A mixture of natural language and high-level
programming concepts that describes the main ideas behind a
generic implementation of a data structure or algorithm
English-like language
Step1: Read a, b, c
Step 2: Compute d=b2 - 4ac
Step 3: If d is positive go to Step X
Step 4: Else if d is negative go to Step Y
Step 5: Else go to Step Z
C-like language
1. Algorithm Max(A, n)
2. //A is an array of size n//
3.{
4. Result=A[1];
5. for i=2 to n do
6. if A[i] > Result then Result = A[i]
7. return Result;
8. }
11
CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd)