Feb 19
homework
Questions / comments / discussion on homework and sorting?
Aside: bucket sort ... O(n) ! Why not use that all the time?
(Answer: isn't a pairwise comparison (a,b), and so need to
know distribution of keys before sorting.)
Midterm assignment : pick a sorting algorithm that we didn't cover.
Read about it, implement it, argue why it's O() is what it is,
and with numerical experiments on random lists
demonstrate that it does indeed have that O() behavior.
Due in two weeks, on March 5.
graphs
chapters 5 & 6 in text : graphs
Many of the classic problems in algorithms are graph problems.
- often recursive
- even the sorting we just did used graphs notions to build the algorithms
Skienna's text starts by building up ideas around graphs
rather than jumping straight to the problems and their algorithms.
(But we will get to some of the classic ones soon
- minimum spanning tree
- shortest path
- traveling salesman
So: here are the questions to address this week :
- What are the properties of graphs?
- How should we represent graphs in a computer program?
- What are the ways to traverse (i.e. visit each node, i.e. search) graphs?
Discuss in class, with your ideas & perhaps some code and/or walk through
Skienna's slides.
Slides :
Aside: software for drawing graphs :
wikipedia: Graphviz .
The most often used command line program is "dot",
which takes files in the .dot language and turns
them into pictures. See
(A common trick I use to generate a .dot file
from a python program.)