0% found this document useful (0 votes)
12 views

3 Intro Algo

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

3 Intro Algo

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

CSC303: Algorithm Design and Analysis I

Audience: B. Tech. (CSE), Semester III

Instructor: Dr. Mamata Dalui


Assistant Professor
Department of Computer Science and Engineering
National Institute of Technology Durgapur

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 study materials/presentations used in this course are solely meant


for academic purposes and collected from different available course
materials, slides, books, etc.

• The study materials presented/ distributed can be reused, reproduced,


modified, and distributed by others for academic purposes only with proper
acknowledgements

CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd) 2


Relationship of Algorithms and
Data Structures
Introduction

• 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

• Algorithmic problem - The statement of the problem provides some


specification of the input and desired output. It also specifies in
general terms the desired input/output relationship.

Input Specification ? Output Specification


as function of input

• 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

CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd) 5


Introduction
• Algorithmic solutions – Algorithm describes the action/set of actions on
the input instance to yield the desired output
• Infinitely many possible correct algorithms may exist for the same
problem

Input instance Desired output as


satisfying the Input Algorithm function of input
Specification

Question
Out of all these possible correct algorithms, which one to choose?

CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd) 6


Why analyze an algorithm at all?

• We classify, not just algorithms but also problems according to their


level of difficulty.
• Most importantly we want to be able to predict performance and
compare algorithms. We want to know how much time our algorithms
are going to take.
• We want to know which algorithm is better than which other one for
our particular tasks.
• While analyzing algorithms, we closely study them which helps to
better understand and improve the performance of particular
algorithms.
• Intellectual challenge - Analysis of algorithms is even more interesting
and fun than programming for many people.

CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd) 7


Introduction

• Algorithm Definition: An algorithm is a finite set of instructions that, if


followed, accomplishes a designated task.
• Essentially, an algorithm must ensure the following criteria:
 No. of external inputs ≥ 0
 No. of outputs ≥ 1
 Finiteness – No. of steps should be finite
 Definiteness – Not be ambiguous
 Effectiveness – If followed manually, will yield same output

CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd) 8


Introduction

• 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

CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd) 9


Contd.

 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. }

CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd) 10


Thank You
Questions?

11
CSC303 Dept of CSE, NIT Durgapur 2024-25(Odd)

You might also like