Algorithms 2018 06 Outline
Algorithms 2018 06 Outline
Class Structure
Recommended Resources
It’s important that you complete the prework for each class. Doing
so will enable you to derive much more value from classes, as we
will mostly be solving problems using the ideas covered in the
readings. We have done our best to keep the prework minimal,
and distinguish “further study” resources for those who may wish to
explore topics in further depth.
2
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
For those who like interactive courseware, Khan Academy has a brief
introductory algorithms course in collaboration with Tom Cormen,
one of the authors of CLRS. It only surveys a handful of topics but is
well produced and includes some short programming exercises.
The bar for “challenging” is different for each of us, but no matter
where you are on your journey there’ll be problems that you won’t
be able to solve simply by staring at them! Our first class will give us
a systematic approach to problem solving that includes exploration,
planning, implementation and revision. We’ll then practice this
approach on a few interesting problems.
There are often many ways to “solve” any given technical problem,
so we need a shared understanding of how we may assess one
approach to be preferable over another. In this class we’ll introduce
algorithmic analysis with Big O notation, and practice by analyzing
some algorithms.
3
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
Pre-class Work
Post-class Work
If we can leave you with just one insight from this entire course, we
hope it is that rigorous problem solving leads to better programs.
So now may be a good time to ask yourself: did your exploration
and planning help you arrive at a neater solution than where your
first instincts would have lead you? Did your solutions improve when
you reminded yourself to revise them after you’d “finished” them?
4
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
Further Resources
5
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
If you come to class with a good understand how these data struc-
tures behave, we’ll be able to focus on the more interesting ques-
tion of how they’re implemented, and how their implementation
might impact their performance.
In-class Exercise
One of the exercises for this class will be to implement and profile a
fast queue.
Post-class Work
After class, please complete and submit your final queue implemen-
tation.
Further Resources
6
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
While you’re reading, you may wish to ask yourself these questions:
7
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
tween the two strategies? When might you want to pick one
over the other?
• If sorting takes (at minimum) O(n log n) time, and binary search
takes O(log n) time, under what circumstances might it worth it
to sort a collection in order to perform binary search?
• For each of bubble, insertion, and selection sort, what are the
best and worse case scenarios?
• Why is the sorting problem a good candidate for divide and
conquer?
Finally, for a bit of fun, see these European folk dancing sort videos.
The inefficient algorithms look tiring!
4. Graph Search
Thursday, 14 June 2018
8
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
shines,11 but by the end of this class you’ll actually appreciate that
11
The stereotypical examples are social
almost anything can be modeled as a graph and almost any problem networks, the web and the internet.
can be solved with graph search. But if we were to emphasize these
examples, you’re likely to come away
In this class we’ll start with simple breadth first and depth first with a narrow view of what is in fact a
very broadly applicable tool.
traversal over trees, and extend our understanding to breadth first
search and depth first search over graphs. By the end, you should
be able to confidently choose between these two strategies, and
implement either one over graphs that you model yourself.12
12
We will stick to unweighted graphs
in this class, even though you are
more likely to encounter graphs where
Pre-class Work edges are weighted. We will need the
algorithms in our next class in order to
be able to adequately deal with these.
Prior to class, you should be able to implement both breadth first
and depth first search over a tree or graph. To achieve this, please
first work through sections 2-4 of Trees and 1-5 of Graphs, in /algos.
Post-class Work
Further Resources
9
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
In-class Exercise
Post-class Work
10
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
Further Resources
Pre-class Work
First, read the recursion section of /algos if you have not already.
On the topic of backtracking, please read this introductory article
as well as Peter Norvig’s fantastic articles Solving Every Sudoku
Puzzle.17
17
Peter Norvig is both an accomplished
researcher and excellent programmer,
While you’re reading, you may wish to ask yourself how exactly currently a director of research at
Google. He is known for co-authoring
the wildly successful textbook Artificial
11 Intelligence: A Modern Approach
as well as—in some circles—for
his influential article Teach Yourself
Programming in Ten Years. He has
also written a number of highly
enlightening essays and interactive
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
After you’ve finished reading, please solve the problem Word Search
and as usual submit your solution to your instructor prior to class.
Post-class Work
Further Resources
7. Dynamic Programming
Monday, 25 June 2018
Post-class Work
Further Resources
13
Problem Solving with Algorithms and Data Structures
June 2018 with Ozan Onay
Epilogue
We hope that this course has helped you take a step or two forward
on this long path, and provided a clearer map of the road ahead.
We would suggest continuing to explore some of the “further
resources” listed above, practicing more problems, and most im-
portantly fostering a playful and positive attitude toward your
relationship with the material. In our experience, those who value
algorithms and data structures—even without a specific objective—
more often find themselves in situations where they can apply their
knowledge, enjoy the process, and complete the virtuous cycle by
deriving motivation for further study!
14