Title: Thinking about Algorithms Abstractly
1Welcome
Thinking about Algorithms Abstractly
Jeff Edmonds York University
Lecture 1
COSC 3101
2Jeff Edmonds www.cse.yorku.ca\jeff\courses\3101
jeff_at_cse.yorku.caCSB 3044, ext. 33295Â
Office hours after class tend to remain outside
the class room. Longer or private questions,
when requested, can be taken back to my office,
CSB 3044. If no one asks, I may or may not rush
back to my office. Other times by appointment or
email. Â
3 Jeff Edmonds "How to Think about
Algorithms". Assignments http//www.cse.yorku.ca
/jeff/courses/3101/ass/ Slides
www.cs.yorku.ca/jeff/notes/3101 Cormen,
Leiserson, Rivest, and Stein "Introduction to
Algorithms", Andy Mirzaian's on-line Lecture
Notes
4- What do you think about 3101?
- Was by far the hardest course ever.
- I got the worst midterm mark ever.
- I almost gave up.
- But opened a door to such an interesting world
for me. - Learned to see things abstractly and from
different angles - After working a few years, I realized that 3101
was the most useful course I took.
5A Contract to Learn
It deeply saddens me when a third of the class
does not learn the material sufficiently to pass.
I will do everything in my power to help you
learn this material.
I request that you do everything in your power.
Everyone can learn it.
6Tough Love
Last year and this summer, I threatened them
every day.
They performed better than ever before!
And my course evaluations were better.
7Think about Algorithms Abstractly
This course requires completely changing the way
you think about algorithms.
Though I keep warning people, they tend not to
get it until they are
Devastated by the midterm
Change your thinking now.
8Study Now!
You spend 50hrs/week on your programming course.
People do work hard on my assignments.
But they dont really study the material
deeplyuntil they fail the midterm.
9Midterms
- We will work you HARD
- 6 assignments
- 5 practice unit tests
- 5 unit tests (every other week)
- An exam
0
-4 if not done
11 5 55
55
10Together
I think it is important for people to not feel
isolated with the material.
11Together
Youre cool! Are you free sometime this weekend?
Yes!The best way to learn is to teach each
other!
12Together
Some students feel too intimidated to talk to the
professor.
Actually, he is just a guywho has been doing
this for a while.
13Together
This term we will provide five hours a week of
contact hours with the TA.
- Ask me anything!
- Class material
- Help YOU solve the assignment questions.
- Material missed from previous courses
- Your love life
14Together
This term we will provide three hours a week of
contact hours with the TA.
- We can have
- Practice Tests
- Lectures
- One-on-one time
- Group discussions
Yes!I will be sure to attend.
15Together
Sorry!I will not have time to mark the
assignments.
- But we can I read your solution together during
the TA hours.
This might be better anyway.
16Together
Lets schedule the office hours now.
17So you want to be a computer scientist?
18Is your goal to be a mundane programmer?
19Or a great leader and thinker?
20Original Thinking
21Boss assigns task
- Given todays prices of pork, grain, sawdust,
- Given constraints on what constitutes a hotdog.
- Make the cheapest hotdog.
Everyday industry asks these questions.
22Your answer
- Um? Tell me what to code.
With more sophisticated software engineering
systems,the demand for mundane programmers will
diminish.
23Your answer
- I learned this great algorithm that will work.
Soon all known algorithms will be available in
libraries.
24Your answer
- I can develop a new algorithm for you.
Great thinkers will always be needed.
25Course 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 lt a.length i)
int j i int B ai while
((j gt 0) (aj-1 gt B))
aj aj-1
j-- aj B
26Course Content
- A survey of algorithmic design techniques.
- Abstract thinking.
- How to develop new algorithms for any problem
that may arise.
27Study
- Many experienced programmers were asked to code
up binary search.
28Study
- Many experienced programmers were asked to code
up binary search.
80 got it wrong Good thing is was not for a
nuclear power plant.
29What did they lack?
30What did they lack?
31What did they lack?
Yes, likely Industry is starting to realize that
formal methods are important. But even without
formal methods . ?
32What did they lack?
- Fundamental understanding of the algorithmic
design techniques. - Abstract thinking.
33Course Content
- Notations, analogies, and abstractions
- for developing,
- thinking about,
- and describing algorithms
- so correctness is transparent
34A survey of fundamental ideas and algorithmic
design techniques
For example . . .
35Some Math
36Iterative Algorithms Loop Invariants
ltpreCondgt codeA loop
ltloop-invariantgt exit when ltexit Condgt
codeB codeC ltpostCondgt
One step at a time
Code
Relay Race
37Recursive Algorithms
38Graph Search Algorithms
39Network Flows
40Greedy Algorithms
NEED A PIC HERE (NOT POOH)
41Recursive Back Tracking
42Dynamic Programing
43Reduction
- Rudich www.discretemath.com
44Useful Learning Techniques
45Read Ahead
- You are expected to read the lecture notes before
the lecture. - This will facilitate more productive discussion
during class.
Also please proof readassignments tests.
Like in an English class
46Explaining
- We are going to test you on your ability to
explain the material. - Hence, the best way of studying is to explain the
material over and over again out loud to
yourself, to each other, and to your stuffed
bear.
47Day Dream
While going along with your day
- Mathematics is not all linear thinking.
- Allow the essence of the material to seep into
your subconscious - Pursue ideas that percolate up and flashes of
inspiration that appear.
48Be Creative
- Ask questions.
- Why is it done this way and not that way?
49Guesses 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.
50RefinementThe best solution comes from a
process of repeatedly refining and inventing
alternative solutions
- Rudich www.discretemath.com
51Useful Learning Techniques
Before reading the solutions to the
assignments.
- Work hard on solving them on your on.
- Study the text and slides.
- Get help, but not answers from friends, TA,
professor,
52Useful Learning Techniques
After reading the solutions to the assignments.
- Study the solutions.
- Understand the solutions.
- Memorize the solutions.
- The questions on the tests will be
different. - But the answers will be surprisingly close.
53Useful Learning Techniques
Please interact with me in class.
Help me know what people are not
understanding Slow down the slides (Though we do
have a lot of material to cover)
54Useful Learning Techniques
Please ask questions!
55Useful Learning Techniques
Please ask questions!
- To keep the flow going
- Wiggly hand relevant to current slide.
- Stationary hand question about past material.
56Useful Learning Techniques
When I ask a question to the class.
Please dont shout out answers. So others can
think.
57Useful Learning Techniques
Please ask questions!
Winter 06, the average of one section was much
higher than the average of the other. (I
taught them both) My theory was that it was
because a student, Gertruda, constantly asked
great questions and everyone learned from
them. Ask questions for everyones sake.
58Two years from now
May I have a letter of reference for grad school?
I find it awkward to write letters for people
that I dont recognize.
Make yourself KNOWN today to SOME professor.
59Two years from now
May I have a letter of reference for grad school?
I find it awkward to write letters for people
that I dont recognize.
Make yourself KNOWN today to SOME professor.
Sorry email does not help as I dont remember
names
60I am not good with names. Emails and test are
effectively anonymous. If you would like a
better rapport with your emails, please include a
picture within the text. ) Jeff
                      Â
61End
Math