INTRODUCTION
CSE-237 : ALGORITHM DESIGN AND ANALYSIS
CONTENTS
Algorithm Characteristics Classifications Complexity
Introduction 2
DEFINITION OF ALGORITHM : WHICH ONE?
A B C
What to How to Do? Why to Do?
Do?
Introduction 3
WHAT IS ALGORITHM?
• An algorithm is simply a set of steps
used to complete a specific task.
✔ Building blocks for programming, and
✔ Allow things to function and make decisions
• Computers, Smartphones, Website
Introduction 4
Which one is NOT Algorithm?
You want to make spaghetti Faster way to reach target!
01 02
Introduction 5
QUALITIES OF A GOOD ALGORITHM
Introduction 6
CLASSIFICATIONS OF ALGORITHM
Introduction 7
HOW FAST WILL YOUR PROGRAM RUN?
Algorithm, Input, Language,Translator
Machine, Operating System, Running Programs
Operations, Branching/Looping, Assignment
Introduction 8
..... .....
for(i=1; i<=n; i++) for(i=0; i<n; i++)
{ {
...... ......
...... ......
} }
....... .......
Which program will FINISH EARLIER?
1 2
Introduction 9
Properties of Algorithm
◆ It should terminate after a finite time.
◆ It should produce at least one output.
◆ It should take zero or more input.
◆ It should be deterministic means giving the same output for the same
input case.
◆ Every step in the algorithm must be effective i.e. every step should do
some work.
Introduction 10
Proving correctness of an algorithm is very important
A well designed algorithm is guaranteed to work correctly and its performance can be estimated.
ALGORITH
PROGRA
M
M
Proving correctness of a program is fraught with weird bugs
Abstract Data Types are a way to bridge the gap between mathematical algorithms and programs.
Introduction 11
You may choose different PLs for different jobs
◆ Python is good for parsing, but could be slow
◆ C++ (c) is probably is one of the choices when speed is the top
priority, complied programming language
◆ Statistics? MatLab & R (free)
◆ Web-programming? php (or asp for windows)
Introduction 12
Textbook
Thomas H. Cormen
1 Introduction to Algorithms
Sartaj Sahni
2 Fundamentals of Computer Algorithms
Introduction 13
Introduction ‹#›
ANALYSIS OF ALGORITHM
Explore it on NEXT DAY