Software Design (CSC-223 97F)
Outline of Class 15: Algorithms
- Discussion about civility in class. I've also prepared
a few short notes on the
- Don't forget Johnny Wong's talk today.
- How's the work going? Is it too much?
- I'm not going to go over the algorithms from the
handout on greedy algorithms.
Please let me know if your have questions.
- Quiz (only for Tony and Omar): answer the questions I posed after
your presentation, giving citations. Turn in your answers (in
HTML form) by 3pm today.
- Assignment seven
is now ready.
- Assignment eight
is also ready. This assignment is optional.
- I'm not going to spend more time on
the manual pages and the appropriate
class outline for more information. Send me email if you
- When you have time (i.e., ASAP), read column 7 of
Bentley's Programming Pearls
- Dan will be giving a talk on Friday.
- Please let me know if you have any requested group changes.
- Although this is primarily a class in software design, alorithms
play a key role in the design of good software.
- Why? Primarily because the choice of algorithm can have as much,
if not more impact, than any coding practices you use.
- I believe that I saw a study showing that a 1960-era computer
running a 1995-era matrix multiplication algorithm has performancee
on par with a 1995-era computer running a 1960-era matrix
- If you're going to write programs that respond sufficiently quickly
(particularly in Java), you're going to need to choose or design
appropriately quick algorithms.
- If you're going to read other people's code, you need to be able to
determine what algorithmic strategy (and, hopefully, algorithm)
they are using.
- Throughout this term, we will look at a number of algorithmic
strategies often employed for making programs more efficient.
- Consider the problem of developing a binary encoding of characters
that minimizes the length of encodings of strings of those characters.
- This is, of course, a way of compressing source texts.
- Suppose you were asked to write an algorithm that computes this encoding,
- What should the inputs to the algorithm be?
- What will the outputs be?
- How can you compare two encodings?
- We'll use an algorithm due to Huffman, which is called
- Don't read on until we've discussed the problem in class!
- Start with a set of characters and probabilities. We'll be using
this set to make a tree, and then reading the code from the tree.
- Repeat the following steps until you have only one element in the
set (only one tree)
- Locate the two "characters" with the smallest probabilities
- Replace them by a single "character" whose probability
is the same as the sum of the probabilities of those characters.
- Record what you've done by making a binary tree whose root
node is the new "character" and whose children are the two
- Read the encoding off the tree. The code for any character is the
path from the root to that character, with 0 representing "left branch"
and 1 representing "right branch".
- Is this a valid encoding? Yes. For any sequence of bits, there is
a unique decoding of that sequence into characters (the binary nature
of the tree helps guarantee this).