cse 3101e design and analysis of algorithms
DESCRIPTION
CSE 3101E Design and Analysis of Algorithms. Prof. J. Elder. Textbooks. Required Text: Cormen, T.H., Leiserson, C.E., Rivest, R.L. & Stein, C. (2001). Introduction to Algorithms , 2nd Ed. Cambridge, Mass: MIT Press. Available in the York University Bookstore - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/1.jpg)
CSE 3101E Design and Analysis of Algorithms
Prof. J. Elder
![Page 2: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/2.jpg)
COSC 3101, PROF. J. ELDER 2
Textbooks
• Required Text:– Cormen, T.H., Leiserson, C.E., Rivest, R.L. & Stein, C. (2001).
Introduction to Algorithms, 2nd Ed. Cambridge, Mass: MIT Press.
• Available in the York University Bookstore
• Also available from www.amazon.ca for $68.01
• Optional Text:– Edmonds, J. How to Think about Algorithms. New York, NY:
Cambridge University Press.
![Page 3: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/3.jpg)
COSC 3101, PROF. J. ELDER 3
Assignments
• You will learn best if you try to tackle each problem by yourself initially.
• You are encouraged to discuss the problems and work in groups to overcome roadblocks.
• You are encouraged to team up with a partner and write up a single assignment report (maximum 2 per group).
• Make the reports as concise and organized as possible. Marks may be taken off for excess verbosity or lack of clarity.
• Late assignments are not excepted (except for medical emergencies – please see syllabus).
![Page 4: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/4.jpg)
COSC 3101, PROF. J. ELDER 4
Teaching Assistant
• Eduardo Corral Soto • Eduardo will be marking all assignments.
• Please direct any questions regarding the marking of assignments to Eduardo.
• If you believe there was an error in marking your assignment, please bring it to Eduardo’s attention promptly (within a week).
• Office hour: Mon 9:30-10:30 (Location TBA)
![Page 5: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/5.jpg)
COSC 3101, PROF. J. ELDER 5
Please ask questions!
Help me know what people are not understanding!
![Page 6: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/6.jpg)
COSC 3101, PROF. J. ELDER 6
On the slides
• These slides:– are available from the website
www.elderlab.yorku.ca/~elder/teaching/cse3101
– may change up to the last minute as I polish the lecture.
– Include slides originally created by J. Edmonds: Thanks Jeff!
![Page 7: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/7.jpg)
COSC 3101, PROF. J. ELDER 7
Lectures
• I will teach the first 18 lectures
• Jeff Edmonds will teach the last 3 lectures on dynamic programming
![Page 8: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/8.jpg)
Lecture 1. What is this course about?
![Page 9: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/9.jpg)
COSC 3101, PROF. J. ELDER 9
Course Content
• A list of algorithms. – Learn their code.
– Trace them until you are convinced that they work.
– Implement them.
– Worry about details. class InsertionSortAlgorithm extends SortAlgorithm {
void sort(int a[]) throws Exception {
for (int i = 1; i < a.length; i++) {
int j = i;
int B = a[i];
while ((j > 0) && (a[j-1] > B)) {
a[j] = a[j-1];
j--; }
a[j] = B;
}}
![Page 10: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/10.jpg)
COSC 3101, PROF. J. ELDER 10
Innovation
Abraham Lincoln
Thomas Edison
Steve Wozniak and Steve Jobs
![Page 11: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/11.jpg)
COSC 3101, PROF. J. ELDER 11
– Knowledge: An up to date grasp of fundamental problems and solutions
– Ability: Principles and techniques that can be adapted to solve new problems
The future belongs to the computer scientist/engineer who has
![Page 12: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/12.jpg)
COSC 3101, PROF. J. ELDER 12
Course Content• A survey of algorithmic design techniques.
• Abstract thinking.
• How to develop new algorithms for any problem that may arise.
![Page 13: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/13.jpg)
COSC 3101, PROF. J. ELDER 13
A survey of fundamental ideas and algorithmic design
techniques
For example . . .
![Page 14: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/14.jpg)
COSC 3101, PROF. J. ELDER 14
Mathematical Tools
Input Size
Tim
e
Classifying Functionsf(i) = n(n)
Recurrence Relations
T(n) = a T(n/b) + f(n)Summations
∑i=1 f(i).
Time Complexityt(n) = (n2)
![Page 15: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/15.jpg)
COSC 3101, PROF. J. ELDER 15
Iterative Algorithms Loop Invariants
i-1 i
ii0 T+1
<preCond> codeA loop <loop-invariant> exit when <exit Cond> codeBcodeC<postCond>
9 km
5 km
Code Relay RaceOne step at a time
![Page 16: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/16.jpg)
COSC 3101, PROF. J. ELDER 16
Recursive Algorithms
?
?
![Page 17: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/17.jpg)
COSC 3101, PROF. J. ELDER 17
Graph Search Algorithms
![Page 18: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/18.jpg)
COSC 3101, PROF. J. ELDER 18
Network Flows
![Page 19: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/19.jpg)
COSC 3101, PROF. J. ELDER 19
Greedy Algorithms
Example: Making Change
![Page 20: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/20.jpg)
COSC 3101, PROF. J. ELDER 20
Dynamic Programing
5 3
4
2 84523
16575
32644
85982
![Page 21: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/21.jpg)
Useful Learning Techniques
![Page 22: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/22.jpg)
COSC 3101, PROF. J. ELDER 24
Read Ahead
You are expected to read the lecture notes before the lecture.
This will facilitate more productive discussion during class.
![Page 23: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/23.jpg)
COSC 3101, PROF. J. ELDER 25
Explaining
• We are going to test you on your ability to explain the material.
• One good way to study is to explain the material over and over again to yourself or to each other.
![Page 24: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/24.jpg)
Be Creative
•Ask questions.
• Why is it done this way and not that way?
![Page 25: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/25.jpg)
COSC 3101, PROF. J. ELDER 27
Guesses and Counter Examples
• Guess at potential algorithms for solving a problem.
• Look for input instances for which your algorithm gives the wrong answer.
• Treat it as a game between these two players.
![Page 26: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/26.jpg)
COSC 3101, PROF. J. ELDER 28
Refinement:The best solution comes from a process of repeatedly refining and inventing alternative
solutions
Rudich www.discretemath.com
![Page 27: CSE 3101E Design and Analysis of Algorithms](https://reader030.vdocuments.us/reader030/viewer/2022013004/5681682f550346895dddd12b/html5/thumbnails/27.jpg)
End