You are on page 1of 22

DESIGN & ANALYSIS OF

ALGORITHMS
Dr: Mahmood Abdel Moneim
Winter 2014
Syllabus
Textbook
Thomas H. Cormen, Charles E. Leiserson,
Ronald L. Rivest, Clifford Stein, Introduction to
Algorithms, McGraw-Hill Book Company ,
Second Edition, ISBN#: 0-07-013151-1

Dr. Mahmood A.Moneim 2


Learning Objectives
By the end of this course, you will have
learned:
1. How to compute and analyze the running time
of algorithms.
2. How to design efficient algorithms
3. The fundamental concepts of algorithms
complexity

Dr. Mahmood A.Moneim 3


Topics covered
Running Time
Growth of Functions
Divide and Conquer Algorithms (Recurrences)
Master Theorem
Dynamic Programming
Greedy Algorithms
Graph Algorithms

Dr. Mahmood A.Moneim 4


Objectives
Introduction to Algorithms
Role of Algorithms
Algorithms within the scope of technology

Dr. Mahmood A.Moneim 5


Algorithms
Given an input
Some value or set of
values
Produce an output
Value or set of values
Using a well-defined
computational
procedure
Known as algorithm

Dr. Mahmood A.Moneim 6


Sorting
Fundamental operation in algorithms
There exist many different types of sorting
algorithms
Ideal to understand algorithm design & analysis
Role
Intermediate step in many larger applications

Dr. Mahmood A.Moneim 7


Why Study Algorithms?
Ideally:
Its fun!
Teaches you great design techniques
Teaches you how to break down problems in
efficient ways
Practically:
How to design good software projects

Dr. Mahmood A.Moneim 8


Dr. Mahmood A.Moneim 9
Problems
Not only sorting
Search Engine Indexing
PageRank - Google
Recommendation Engines
Policing Crime Reduction
Analytics (analyzing personal/learning
behavioral habits)
Science

Dr. Mahmood A.Moneim 10


Shortest Path

Dr. Mahmood A.Moneim 11


Practical Example: Searching
FindDefinition(w, dictionary)
for every page in the dictionary
If w is in the page
return definition
Can we do better?

Dr. Mahmood A.Moneim 12


Practical Example: Searching
FindDefinition(w, dictionary)
Set middlePage to half of dictionary (size / 2)
If w is in the middlePage
return definition
otherwise discard half

Dr. Mahmood A.Moneim 13


Characteristics
Correctness
For every input instance, algorithm halts with correct
output
Easy to implement
Efficient
Measured by speed
Not all algorithms/problems are efficient (NP-
Complete)
e.g. traveling salesman problem

Dr. Mahmood A.Moneim 14


Algorithms & Technology
Focus of the course is to study algorithms as
mathematical objects
Reality is, computing time is bounded by
resources
Only efficient algorithms will wisely utilize time
and/or space
Not all algorithms solve a problem the same way
Differences in algorithmic implementation can have
more significance than differences in hardware or
software

Dr. Mahmood A.Moneim 15


Different Approaches
Consider two sorting algorithms:
Insertion Sort
Time proportional to 12
Merge Sort
Time proportional to 2 2
Which is faster?

Dr. Mahmood A.Moneim 16


Predicting Computational Time
Problem Statement: Sort 1M numbers (106)
Consider two machines: A & B

Dr. Mahmood A.Moneim 17


Predicting Computational Time

What happens when increases? e.g. 10M?

Dr. Mahmood A.Moneim 18


Brief Analysis
Similar to computer hardware, algorithms are
also considered a technology.
Thus, performance is largely based on
efficient algorithms as well as fast hardware

Dr. Mahmood A.Moneim 19


Summary
Concept of algorithm
Role of Algorithms
Algorithms and Technology

Dr. Mahmood A.Moneim 20


Next Lecture
Designing Algorithms
Analyzing Algorithms
Computing Cost
Computing Running Time

Dr. Mahmood A.Moneim 21


QUESTIONS?

Dr. Mahmood A.Moneim 22

You might also like