Introduction
Introduction
Algorithms
Dr. Truong Dinh Huy
My Self
• Dr. Truong Dinh Huy
• Office: Room 389, Admin Building
• E-mail: [email protected]
• Major: IoT, Deep Learning for IoT, Reinforcement Learning
• Office hours: every Tuesday 2pm-4pm
Course Content
1. Asymptotic Analysis
2. Data Structures:
• Linear data structures: List, Stacks, Queues,…
• Non-linear data structures: Tree, Graph
3. Algorithms:
• Basic: Sorting, Searching, Hashing
• Advance: Graph Algorithms (Depth first Search, Breadth First Search,
Shortest-Path algorithms,…)
4. Algorithm Design Techniques:
• Greedy Algorithm
• Divide and Conquer
• Dynamic Programming
• …
Course Workload
Assessment
1. 4 Assignments: 40%. Open-book but no electric devices
2. Final Exam (90 minutes written exam): 60%. Printed materials are allowed in exam room
and no electric devices
Notes:
1. 4 Assignments will be done at lecture hall.
2. Prerequisites: Students are allowed to take part in the module examination if the student
attended at least 75% of total number of lectures.
3. For students who do not follow this rule like 2020-students or 2019-students: To be
allowed to take part in the final Exam, you must do all homework and submit them to
specific folder named Submitted Homework.
Materials
Recommended Textbook:
1. Data Structures and Algorithm Analysis in C, Mark Allen Weiss
18/03 Lecture Hall Sorting I 13/05 Lecture Hall Online Assignment 3 &
Graph 1
25/03 Lecture Hall Sorting II & Searching 20/05 Lecture Hall Graph 2
01/04 Lecture Hall Online Assignment 1 & 27/05 Lecture Hall Minimum spanning Tree
Linked List
08/04 Lecture Hall Stack, Queue 03/06 Lecture Hall Online Assignment 4 &
Algorithm Design
Techniques
15/04 Lecture Hall Tree 1 10/06 Lecture Hall Dynamic Programming &
Course Review
22/04 Lecture Hall Online Assignment 2 &
Tree 2
Course Motivation
Need to write computer programs efficiently!
Computer program:
Accepts Input (Data)
Performs a Sequence of action with the input
Generates Output (Data)
How?
Efficient Management of Data the efficiency of your algorithm:
Data Structures Run time
Storage required
Efficient Sequence of Actions
There is usually a trade-off between runtime and
Algorithms storage required
Example
• All these structures are there to efficiently store and
process data
sumq(3, 6) = 19
9
Example
• All these structures are there to efficiently store
and process data
sumq(3, 6) = 19
Slower way
10
Example
• All these structures are there to efficiently store and
process data
sumq(3, 6) = 19
Auxiliary Prefix Sum Array P:
Cooler/faster way
P[i] = A[0] + A[1] +… + A[i]
11
Example
• All these structures are there to efficiently store and
process data
12
Example
• All these structures are there to efficiently store
and process data
A:
P:
13
Example
• All these structures are there to efficiently store
and process data
• Problem: find the sum of a subarray quickly.
• How to compute Prefix Sum Array P?
– Dead simple application of dynamic programming:
• P[0]=A[0]; for(i=1 to n-1) P[i]=P[i-1]+A[i];