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 [Link] 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 [Link] 3
Topics covered
Running Time
Growth of Functions
Divide and Conquer Algorithms (Recurrences)
Master Theorem
Dynamic Programming
Greedy Algorithms
Graph Algorithms
Dr. Mahmood [Link] 4
Objectives
Introduction to Algorithms
Role of Algorithms
Algorithms within the scope of technology
Dr. Mahmood [Link] 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 [Link] 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 [Link] 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 [Link] 8
Dr. Mahmood [Link] 9
Problems
Not only sorting
Search Engine Indexing
PageRank - Google
Recommendation Engines
Policing Crime Reduction
Analytics (analyzing personal/learning
behavioral habits)
Science
Dr. Mahmood [Link] 10
Shortest Path
Dr. Mahmood [Link] 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 [Link] 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 [Link] 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 [Link] 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 [Link] 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 [Link] 16
Predicting Computational Time
Problem Statement: Sort 1M numbers (106)
Consider two machines: A & B
Dr. Mahmood [Link] 17
Predicting Computational Time
What happens when increases? e.g. 10M?
Dr. Mahmood [Link] 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 [Link] 19
Summary
Concept of algorithm
Role of Algorithms
Algorithms and Technology
Dr. Mahmood [Link] 20
Next Lecture
Designing Algorithms
Analyzing Algorithms
Computing Cost
Computing Running Time
Dr. Mahmood [Link] 21
QUESTIONS?
Dr. Mahmood [Link] 22