You are on page 1of 31

DESIGN AND

ANALYSIS OF
ALGORITHMS
Course Code : AR212
Credit Hours :3
Prerequisite : AR211
Instructor Information

Name :Dr. Aryaf Abdallah Aladwan


Office No. --
Tel (Ext) None
E-mail aryaf_aladwan@bau.edu.jo
Office Hours Sun, Tue, Thu 10:00-11:00, 15:00-16:00
Class Times Building Day Start Time End Time Room No.
AI Sun -Tue, :0014 :0015 AI LAB
Thu
Salt Technical Sun -Tue, 12:00 :0013 8
College Thu
This course is to design efficient computer algorithms, prove their
correctness, and analyze their running times. it includes mathematical
analysis of algorithms (summations and recurrences), advanced data
structures (balanced search trees), algorithm design techniques (divide-
and-conquer, dynamic programming, and greedy algorithms), graph
algorithms (breadth-first and depth-first search, minimum spanning
trees, shortest paths).
Course Title: DESIGN AND ANALYSIS OF ALGORITHMS
Credit Hour(3)

[Pre-req. AR211
Textbook: Introduction to Algorithms, Thomas Cormen, Charls Leiserson & Ronald Rivest. 3rd Edition,
MIT Press, 2009.

Image of the textbook Cover


COURSE OBJECTIVES

The main learning objectives of the course are to:


1. Learn about the use of several design techniques and the importance of studying the complexity of
a particular algorithm
2. Computational complexity analysis of algorithms and worst-case algorithm runtime analysis using
asymptotic analysis and mathematical analysis of algorithms (summations and recursion)
3. Writing and analyzing recursive relationships for recursive algorithms
4. Describe the divide and conquer approach as a principle for algorithm design
5. Learn about searching and sorting algorithms
6. Ability to design, analyze and validate graph algorithms and shortest path algorithms
7. Ability to design and analyze algorithms that follow the approach of greedy algorithms
8. Understand dynamic programming algorithms and optimization algorithms and know when the
algorithm design situation calls for it.
9. Learn about advanced data structures
COURSE SYLLABUS

Week Course Topic


Week 1 Introduction to Algorithms, The Efficiency of Algorithms, Attributes of Algorithms. A Choice of
Algorithms. Classifications of algorithms: by implementation, by design, by field of study and by
complexity.
Week 2 Mathematical Background (summations and recurrences)
Week 3 Measuring Efficiency, Measuring the asymptotic growth of functions. The basic techniques for
manipulating bounded summations, searching techniques (linear search, binary search).
Week 4 Techniques for problem-solving: Divide and Conquer, the General Method, Recurrence Equations,
Solving Recurrence Equations (Master and iteration Methods).
Week 5 and 6 Sorting techniques based on Divide and Conquer: Merge Sort.
Quick Sort, Strassen's Matrix Multiplications.
Week 7 Other sorting techniques: Insertion sort, Selection Sort, Heap Sort
Week 8 Midterm Exam
Week 9 Graph Algorithms, Formal Definition of Graphs. Graphs Types.
Graph Terminologies, Strongly Connected Graph, Representations of Graphs.
Week 10 Graph Traversal, Breadth-First Search Algorithm, Depth-First Search Algorithm. Topological Sort
Algorithm.
Week 11 Greedy Algorithms, Minimum spanning trees
Week 12 Shortest paths algorithms
Week 13 Dynamic Programming
Week 14 Optimization Algorithms
Week 15 Advanced data structures (balanced search trees)
Week 16 Final Exam
Week 2
Design and Analysis of Algorithms Course

Chapter 2
Mathematica
l
Background
Dr. Aryaf Al-Adwan
Autonomous Systems Dept.
Design and Analysis of algorithms
Course Dr. Aryaf Al-Adwan

8
Outlin
e1. Review of Necessary Mathematics
2. Summations
3. Mathematical Induction
4. Functions In particular, it is not assumed that you
have studied calculus. However, a
5. Logarithms certain amount of mathematics is
6. Recurrences  Later necessary for the analysis of algorithms.
This chapter reviews that necessary
mathematics. You may already be
familiar with much or all of this material.

Dr. Aryaf Al-Adwan 9


Necessary Mathematics
(Notations)

• ⌈x⌉ is the ceiling for x, ⌈3.3⌉ = 4, ⌈-2.4⌉ = -2


• ⌊x⌋ is the floor for x, ⌊3.3⌋ = 3, ⌊-2.4⌋ = -3
• The sum of the first seven positive integers, we simply write

• The sum of the first 100 positive integers:

• We use Σ to represent the sum of the first 100 positive integers as follows:

Dr. Aryaf Al-Adwan 10


Cont
.
• Often we want to denote the case in which the last integer in the sum is an arbitrary integer n.
Using the methods just illustrated, we can represent the sum of the first n positive integers by

• Similarly, the sum of the squares of the first n positive integers can be represented by

• Sometimes we need to take the sum of a sum. For example,

Dr. Aryaf Al-Adwan 11


Summation
(Sigma)
• A series can also be represented by using summation notation, which uses the Greek letter ∑ (capital sigma) to
denote the sum of a sequence defined by a rule, as shown.

• Write the series in summation notation:


4 + 8 + 12 + 16 + 20

• Write the series in summation notation:

Dr. Aryaf Al-Adwan 12


Exampl
e• Expand each series and evaluate?

Dr. Aryaf Al-Adwan 13


Cont
.

Dr. Aryaf Al-Adwan 14


Summation
Rules

5.

6.

Dr. Aryaf Al- wan


Ad
Exampl
e• Using the previous rules and properties from above determine the value of the following
summation:

Dr. Aryaf Al-Adwan


Mathematical Induction

• Mathematical Induction is a mathematical technique which is used to prove a statement, a


formula or a theorem is true for every natural number.
• Mathematical induction works in the same way as the domino principle

If we knock over the first domino, it will knock over the second, the second will knock over the third,
and so on. In theory, we can have an arbitrarily large number of dominoes, and they all will fall.
17
Dr. Aryaf Al-
Cont
.
• An induction proof works in the same way. We first show that what we are trying to prove is true for n = 1.
Next we show that if it is true for an arbitrary positive integer n, it must also be true for n + 1. Once we have
shown this, we know that because it is true for n = 1, it must be true for n = 2; because it is true for n = 2, it
must be true for n = 3; and so on, ad infinitum (to infinity). We can therefore conclude that it is true for all
positive integers n.
• When using induction to prove that some statement concerning the positive integers is true, we use the
following terminology:
1. The induction base is the proof that the statement is true for n = 1 (or some other initial value).
2. The induction hypothesis is the assumption that the statement is true for an arbitrary n ≥ 1 (or some
other initial value)
3. The induction step is the proof that if the statement is true for n, it must also be true for n + 1.
Example
1 Show using the mathematical induction for all positive integers n, that
  Equation 1

Dr. Aryaf Al-Adwan


 Substitute in Equation 1

Dr. Aryaf Al-Adwan


Example
2 Show using the mathematical induction for all positive integers n, that
  Equation 1

Dr. Aryaf Al-Adwan


 Substitute in Equation 1

Assignment 1
Prove Rule 5 in slide 8 using the
mathematical induction.

Dr. Aryaf Al-Adwan


Function
s
• A function determines a set of ordered
pairs.
• For example, the function f (x) = x2
determines all the ordered pairs (x, x2).
A graph of a function is the set of all
ordered pairs determined by the
function.

Dr. Aryaf Al-Adwan


Common
Functions
1.F(n) = Log n 
logarithmic 2.F(n) = n 
linear
4.F(n)
3.F(n) = n2log n   quadratic
logarithmic
5.F(n) = n3 linear  cubic
6.F(n) = nn  exponential
7.F(n) = 2n  exponential
8.F(n) = n!  factorial

Dr. Aryaf Al-Adwan


Dr. Aryaf Al-Adwan
Dr. Aryaf Al-Adwan
Logarithm
s

Dr. Aryaf Al-Adwan


Cont
.

Dr. Aryaf Al-Adwan


Properties of
Logarithms

Dr. Aryaf Al-Adwan


Dr. Aryaf Al-Adwan
Dr. Aryaf Al-Adwan

You might also like