USTH Introduction
USTH Introduction
USTH Introduction
Algorithm
• COURSE DESCRIPTION
Subject: Introduction to Algorithm • Computational Thinking
Lecturer: Hoang Do Thanh Tung • Why to study algorithms?
• Some simple examples
Credit points 3 ECTS
Level Undergraduate • How to study algorithms?
Teaching time
University of Science and Technology of Hanoi
Location
COURSE DESCRIPTION
Course Goals
Give introduction to Algorithms
For the students, who take the first algorithm course, to imagine
what/why/how is to study algorithms
Learn how to express algorithms with pseudo-code and diagram.
Text Book and Reference Books
Text Book:
Jeff Erickson. Algorithms. Independently published. 2019.
Mark A. Weiss . Data Structures & Algorithm Analysis in C++ 4th
Edition. Pearson, 2014.
Reference Books:
Sanjoy Dasgupta. Algorithms. McGraw-Hill, 2006.
Cormen, Leiserson, Rivest, Introduction to Algorithms, 2nd Ed.,
MIT Press, 2001.
Examination and Grading
Examination
A midterm exam with an assignment
A final exam
Grading
Attendance/Attitude 10%
Class exercise and Lab practices 20%
A midterm exam 20%
Final exam 50%
Course Prerequisite
You are totally able to read my slides, course books, materials in internet so
We don’t have to be hurry to fulfill all slides
We try to understand each step we reach
You don’t ask me for solutions first,
You give me problems you meet
You try to find the solutions yourself with your computer first
We discuss about the result
Algorithm: A brief History
Bus ($2 )
Taxi, Grab bike (> $3)
Speed >= Subway
An algorithm for singing that annoying song ‘99 Bottles of Beer on the Wall’,
for arbitrary values of 99:
So What is an algorithm for Computer?
An algorithm is a sequence of unambiguous instructions for
solving a problem
input
output
Properties of computer Algorithms
sorting
searching
string processing
graph problems
combinatorial problems
geometric problems
numerical problems
Programming vs. Problem Solving
Theoretical importance
Practical importance
i 1
Pseodocode:
Algorithm Euclid(m, n)
while n ≠ 0 do
r m mod n
mn
nr
return m
Other methods for computing gcd(m,n)
Consecutive integer checking algorithm
Step 1 Assign the value of min{m,n} to t
Step 2 Divide m by t. If the remainder is 0, go to Step 3;
otherwise, go to Step 4
Step 3 Divide n by t. If the remainder is 0, return t and stop;
otherwise, go to Step 4
Step 4 Decrease t by 1 and go to Step 2
There might exists more than one algorithm for a certain problem.
Algorithms for the same problem can be based on very different ideas and can
solve the problem with dramatically different speeds.
How do we check attendances in a class?
How to study algorithms?
Basic Issues to study Algorithms
Go straight on to the traffic lights, turn left and take the third turning on the right. If the
red gate is open then go through it, otherwise go through the green gate.
Algorithm Representation Example
Flowchart:
Algorithm Design and Analysis Process
Algorithm Design
Techniques/Strategies
Brute force Greedy approach
Backtracking
Decrease and conquer