Lec01 Introduction New
Lec01 Introduction New
Attendance
80% (MUST)
If absent, please justify with valid reason
If sick, then provide MC
If has parttime job, please get an official letter from your employer with
stamp and sign
Inform within one week after absent
If attendance is extremely low, either withdraw or bar
ERU will run the attendance calculation on 9 December. Any
justification and attendance issue must solve before that
It is not an faculty issue, it is the whole university, please treat it
seriously
Replacement class
Original Date/Time Original Venue Replace Date/Time Replace Venue
GPY8 https://teams.microsoft.com/l/meetup-join/19%3ameeting_NTUzZDAzNmQtNDY4Ni00NDUyLTg3YTYtMjBhNDEwOTExZWMy%40thread.v2/0?context=%7b%
Goh Pey Yun, 3/18/2024
GPY9 https://teams.microsoft.com/l/meetup-join/19%3ameeting_NmVjZTc3NWItYzJlNS00MzU1LTljZDQtODcxNmNlZDRmM2I1%40thread.v2/0?context=%7b%22T
Goh Pey Yun, 3/18/2024
GPY10 https://teams.microsoft.com/l/meetup-join/19%3ameeting_ZTU1ZWVkZGYtOWY4OC00M2U4LWE2ZjctMjE2Yjc5OWM4Njc0%40thread.v2/0?context=%7b%2
Goh Pey Yun, 3/18/2024
Learning Outcomes of the course
Main
Jon Kleinberg (2015). Algorithm Design (2nd ed.). Addison Wesley.
Harsh Bhasin (2015). Algorithms: Design and Analysis. Oxford University
Press.
Dwivedi, Gyanendra Kumar (2017). Analysis and Design of Algorithm.
University Science Press.
Additional
1. Robert Sedgewick and Philippe Flajolet (2013) Introduction to the Analysis
of Algorithms (2nd ed.). Addison Wesley.
2. Michael Soltys-Kulinicz (2018). Introduction to the Analysis of Algorithms
(3rd ed.). World Scientific Publishing.
3. Anany Levitin (2013). Introduction to the Design and Analysis of Algorithms
(3rd ed.). Addison Wesley. 4. Anany Levitin (2013). Introduction to the Design
and Analysis of Algorithms (3rd ed.). Addison Wesley.
Importance of Algorithms
To solve problem with proper procedures, just like the SOP for
covid19
Some existing applications:
To search by typing a query in Google
Output: ordered set of results mostly relevant to the query are
presented
How Google able to do it?
Use page rank algorithm, ranks the relevant pages based on the
entered query
To combat terrorism
Develop a global database of DNA
Use sorting and searching algorithms to mine information among
billions of DNAs
Optimisation
In business, minimizing cost and maximizing profit is a critical task
Greedy algorithm helps in achieving the task of optimisation
Representative Problem: Stable Matching
Stable:
Since Jimmy has accepted the offer from company B so he said no to
company C.
Then, company C offers the internship to Mary.
All outcomes are stable.
Stable Matching
Company B Student
Student 1 1 Student 2 Student 3
m1: w1 w2 m1 w1
m2: w2 w1
w1: m2 m1
w2: m1 m2 m2 w2
We need to know:
Will the algorithm terminate? ~ demo
Will it runs as it is i.e. to provide a stable match? ~ proof by logic such
as contradiction
Can it runs within an acceptable time frame? ~ proof by growth
function
Why study algorithm design and analysis?
𝑙𝑜𝑔 𝑎 = 𝑐 if 𝑎 = 𝑏
Logarithms: how many times a number b has been multiplied by itself in order to obtain value a
When b = 2, it is not written.
Let a, b, c be positive real numbers:
𝑙𝑜𝑔 𝑎𝑐 = 𝑙𝑜𝑔 𝑎 + 𝑙𝑜𝑔 𝑐 - rule 1
= 𝑙𝑜𝑔 𝑎 − 𝑙𝑜𝑔 𝑐 - rule 2
𝑙𝑜𝑔 𝑎 = 𝑐𝑙𝑜𝑔 𝑎 - rule 3
( )
𝑙𝑜𝑔 𝑎 = - rule 4
𝑏 =𝑎 - rule 5
(𝑏 ) = 𝑏 - rule 6
𝑏 𝑏 =𝑏 - rule 7
𝑏 /𝑏 = 𝑏 - rule 8
Rule 1 – 4 ~ logarithms
Rule 5 – 8 ~ exponents
Exercise: Logarithms (10 minutes)
=? • log 2𝑛𝑙𝑜𝑔𝑛 = log 2 + log 𝑛 + log log 𝑛 = 1 +
log 𝑛 + log log 𝑛 (rule 1, twice)
n=? • log = log 𝑛 − log 2 = log 𝑛 − 1 (rule 2)
• 𝑙𝑜𝑔 𝑛 = (log 𝑛)/ log 4 = (log 𝑛)/2 (rule 4)
=? • log 2 = 𝑛 log 2=n (rule 3)
• 2 = (2 ) = 𝑛 (rules 5 & 6)
• 𝑛 2 = 𝑛 𝑛 = 𝑛 (rules 5, 6 & 7)
=? • 4 /2 = =2 =2
?
Math you Need to Review: Proof Techniques
Thus, ab is even. T T F F T T
T F F T F F
As a conclusion: If ab is odd, then a is odd or b is F T T F T T
even is true. F F T T T T
Probability of picking a red marble from a jar that contains 4 red marbles
and 6 blue marbles. What is the probability of picking a blue marble?
6/10
Problem Development Steps
Computer algorithm:
To solve a problem with a set of steps which describe precisely how
the computer can run
Steps of operations
Performing calculation or
Data processing or
Automated reasoning tasks
Best way to represent the solution of a particular problem in a very
simple and efficient way
Independent from any programming languages
Algorithms
Correctness
Must produce correct result
If cannot avoid the error/wrong result, need to know the possible
failures, for e.g.: 1 failure out of 1000 execution
Approximation algorithm: optimization solution is available when exact
solution is not found
Less resource
Time
space
Design and Analysis VS Analysis and Design
Decide on:
Computational means, exact
vs. approximate solving,
algorithm design technique
Design an algorithm
Running Time
80
Programming language 40
To know the relationship between running time and the size of input n, we can use these techniques:
Experimental Studies
Theoretical Analysis
Experimental Studies
Time (ms)
5000
Use programming 4000
language’s time method to
get an accurate measure of 3000