Upcoming Assignments
(Some of this work has been previously assigned. If you've
already been working on it, great! Get it done and move on.)
resetting the numbering system to avoid confusion
Note: there are two separate themes here. We'll
interleave (leapfrog) them.
HW 10: due Monday Nov 12
You should have worked with the binary [search] tree code from
Lafore. Add in some capability for filling the tree with
pseudo-random values (using class Random and nextInt()), and for
timing the search time (using System.getTimeMillis()).
(The timing can be preliminary; there's a chance to do it
more completely coming up next week)
Note: measuring the time can be tricky, as the tools are fairly
coarse. A 2 GHz process can easily execute a million operations
in one millisecond! Thus you'll need to repeat -- many times --
whatever you're trying to measure.
NO CLASS on Monday Nov 12 -- Veterans' Day Holiday
Suggestion: if your performance on the hour exam was weak,
try re-taking the test during this [free] time on Monday.
Hopefully, you've looked at the problems you got wrong, and now
understand how to do them properly What better way to check that
than to take a blank sheet of paper and write out the answers (without
looking at the solution sheet or your notes!)
HW 11: due Wednesday Nov 14
Make some improvements in the recursive tree-walk capability of
the binary tree program.
- Alter the existing pre-order tree-walk so it will print in a more
intelligble fashion. Suggested: one item per line, either
labeled with the level, or indented according to level. (It
should be possible to reconstruct the tree, unambiguously, from what's
printed)
- Write a function to determine the maximum nesting depth of the
tree.
- Write a function to determine the total number of nodes in the
tree.
HW 12: due Monday Nov 19
Do a performance analysis of several different search
algorithms, including:
- ordered array
- hash table
- binary [search] tree
- 2-3-4 trees (extra credit)
For each algorithm, measure it at three different size points.
Make a rough graph to show what you've found. Does this have any
connection with the big-O values we've been claiming?
All of these algorithms are provided by Lafore. Feel free to pick
up clean copies from the web site.
Object: learn something more about the algorithms themselves, as
well as learning how to go about doing performance analysis.
It would also be interesting to measure the time to create the data
structure (the "insert" phase). (extra credit)
Note that you could spend weeks doing this kind of analysis,
averaging results, doing statistical checks ... so perfection is not
required! This assignment requires that you do enough so you can
see the trend, and understand how to go about making effective
measurements. Keep your eyes open, there are lots of possible
insights in this kind of work.
HW 14:
Similar to #12, but here we'll be looking at sorting algorithms
- insertion sort
- selection sort
- merge sort
- Shell sort
Note that this may be a little trickier to time that the "find"
function, because it's not so easily repeated: once the array is
sorted, you can't just do it again. Happily, computer memories
are pretty large, so you might be able to create an array sufficiently
large so that sorting it once takes long enough to measure.
We'll talk about Shell sort presently.
For extra credit: in addition to using randomly chosen values,
try measuring the "best" and "worst case" situations -- where the array
is already sorted, and when the data is sorted but in the wrong
order. Some of the results may be surprising.