Lecture 1 - Intro
Lecture 1 - Intro
ALGORTIHMS
• Attendance Policy: You should attend at least 70% of classes to pass the course.
Pearson https://www.cs.princeton.edu/~wayne
/kleinberg-tardos/pearson/
SUGGESTED BOOKS
Addison - Wesley
https://aofa.cs.princeton.edu/home/
GOALS understand
algorithms and
design
introduce techniques to
the classic solve problems
algorithms
learn the
complexities
Compare of various
algorithms algorithms
SYLLABUS
Week (Lec ) Topic
Week 1 Introduction to Algorithm
Week 2 Algorithms Analysis
Week 3 Searching Algorithms
Week 4 Sorting Algorithms
Week 5 Brute Force Algorithms
Week 6 Divide-and-Conquer Algorithms
Week 7 Decrease-and-Conquer Algorithms This outline shows the
Week 8 Graph Algorithms 1 list of topics associated
with each class meeting.
Week 9 Graph Algorithms 2
Week 10 Dynamic programming However, it is tentative
Week 11 Greedy Technique and subject to change as
seen necessary and
Week 12 NP-Complete Problems appropriate during the
Week 13 Special interests semester.
Week 14 Wrap-Up
W H AT A R E A L G O R I T H M S
AND
WHY SHOULD YOU CARE?
QUESTIONS IN MINDS
• What are algorithms?
KEVIN WAYNE -
ALGORITHMS
and DATA
STRUCTURES -
2021
Artificial Intelligence
Data processing Algorithms are used to develop
Algorithms are used to process intelligent systems, such as ML
and analyze large amounts of algorithms, natural language
data, such as sorting and processing algorithms, and
searching algorithms. computer vision algorithms.
• Fun
– Algorithms is still a young area, and there are still
many mysteries, and many problems for which we
still do not know the best algorithms Algorithm designer
HOW MANY SHORTEST PATH
ALGORİTHMS ARE THERE?
1. Shortest Path Algorithm using Depth-First Search(DFS
2. Breadth-First Search (BFS) for Shortest Path Algorithm
3. Multi-Source BFS for Shortest Path Algorithm
4. Dijkstra’s Algorithm for Shortest Path Algorithm
5. Bellman-Ford algorithm for Shortest Path Algorithm
6. TopoLogical Sort
7. Floyd-Warshall algorithm for Shortest Path Algorithm
8. A* Search Algorithm for Shortest Path Algorithm
9. Johnson’s Algorithm for Shortest Path Algorithm
WHY STUDY ALGORITHMS?
Job Interviews
YES!
You should use these resources wisely, and algorithms that are
efficient in terms of time or space will help you do so.
Algorithm
design and
analysis
process
FUNDAMENTALS
OF ALGORITHMIC
PROBLEM
SOLVING
A COMMON PROBLEM
• Sorting is a fundamental operation in computer science.
We have a large
number of good
.
sorting algorithms
ALGORITHM DESIGN TECHNIQUES
How do you sort a cart of books in
increasing order of the volume number?
(i.e. volume 1, volume 2, volume 3....)?
Bad algorithm: compare all books, put the
smallest volume in the beginning, and
repeat. (Brute Force)
! https://www.enjoyalgorithms.com/blog/find-the-minimum-and-maximum-value-in-an-array
A PROBLEM YOU ALL KNOW HOW TO SOLVE:
INTEGER MULTIPLICATION
12
x 34
A PROBLEM YOU ALL KNOW HOW TO SOLVE:
INTEGER MULTIPLICATION
1234567895931413
x 4563823520395533
A PROBLEM YOU ALL KNOW HOW TO SOLVE:
INTEGER MULTIPLICATION
n
1233925720752752384623764283568364918374523856298
x 4562323582342395285623467235019130750135350013753
???
How would you solve this problem?
How long would it take you?
About 𝑛𝑛2 one-digit operations
At most 𝑛𝑛2 multiplications,
and then at most 𝑛𝑛2 additions (for carries)
and then I have to add n different 2n-digit numbers…
And I take 1 second to multiply two one-digit numbers and .6 seconds to add, so…
Slide from Huma Ayub
Let the two given numbers be 'a' and 'b'
1) Initialize result 'res' as 0.
2) Do following while 'b' is greater than 0
a) If 'b' is odd, add 'a' to 'res'
b) Double 'a' and halve 'b'
3) Return 'res'.
Slide from Huma Ayub
WHICH ALGORITHM IS BETTER?
All the algorithms are correct, but which is
the best?
• Measure the running time (number of operations
needed).
• Measure the amount of memory used.
• Note that the running time of the algorithms
increase as the size of the input increases.