Lecture 1 2 - Introduction
Lecture 1 2 - Introduction
1
CS 854 – Advanced Algorithm Analysis
2
Recap
• Asymptotic Notations
• Types of Asymptotic Notations
• Recurrences
• Methods to solve recurrences
• Substitution Method
• Recursion Tree Method
• Master Method
• Properties of Algorithms
• History of Algorithms
• Design of Algorithms
• Designing Techniques
• Algorithm Efficiency
4
General Conduct
• Be respectful of others
• Only speak at your turn and preferably raise your hand if you
want to say something
• Do not cut off others when they are talking
• Be punctual
5
Algorithm Definition
• An algorithm is a step-by-step procedure for solving a particular
problem in a finite amount of time.
Input ALGORITHM
Some mysterious Output
X processing Y = F(X)
F: X→Y
6
Algorithm -- Examples
• Repairing a lamp
• A cooking recipe
• Calling a friend on the phone
• The rules of how to play a game
• Directions for driving from A to B
• A car repair manual
• Human Brain Project
• Internet & Communication Links (Graph)
• Matrix Multiplication
7
Algorithm vs. Program
• A computer program is an instance, or concrete representation,
for an algorithm in some programming language
8
High Level
Language
Program
Solving Problems (1)
When faced with a problem:
1. First clearly define the problem
3. Select the one that seems the best under the prevailing
circumstances
9
Solving Problems (2)
• It is quite common to first solve a problem for a particular case
• Then for another
• And, possibly another
• And watch for patterns and trends that emerge
• And to use the knowledge from these patterns and trends in
coming up with a general solution
• And this general solution is called …………….
“Algorithm”
10
One Problem, Many Algorithms
Problem
• The statement of the problem specifies, in general terms, the
desired input/output relationship.
Algorithm
• The algorithm describes a specific computational procedure for
achieving input/output relationship.
Example
• Sorting a sequence of numbers into non-decreasing order.
Algorithms
• Various algorithms e.g. merge sort, quick sort, heap sorts etc.
11
Problem Instances
• An input sequence is called an instance of a Problem
• It must be correct.
• It must terminate.
13
Syntax & Semantics
An algorithm is “correct” if its: WARNINGS:
• Semantics are correct
• Syntax is correct 1. An algorithm can be
syntactically correct, yet
semantically incorrect –
Semantics: dangerous situation!
Colorless
• The conceptgreen
embeddedideas
in sleep furiously!
an algorithm (the soul!) 2. Syntactic correctness is
easier to check as
compared to semantic
Syntax: correctness
• The actual representation of
an algorithm (the body!)
14
Brief History
• The study of algorithms began with mathematicians and was a
significant area of work in the early years. The goal of those early
studies was to find a single, general algorithm that could solve all
problems of a single type.
16
Designing of Algorithms
• Selecting the basic approaches to the solution of the problem
• Choosing data structures
• Putting the pieces of the puzzle together
• Expressing and implementing the algorithm
• clearness, conciseness, effectiveness, etc.
18
Important Designing Techniques
• Brute Force–Straightforward, naive approach–Mostly expensive