Preface:
Since this is the very first assignment, let me take a few moments
to discuss some general issues, before discussing specifics about
assignment 1.
Please make sure that you are aware of our Collaboration Policy, as any
violations will be taken seriously.
Click to see details about computer accounts or
about how to submit your
source code and readme file when complete.
Also make sure that you are aware of our Late Policy. On this note, we want
to make sure that you realize that these assignments will require a
good deal of time. The final source code may not be that long (I am
sure that I could probably do each assignment with under 80 lines of
code, and Professor Sedgewick can do it in 40 lines), however finding
and debugging the code is a serious time commitment. Also please
note that precepts are scheduled for Mondays and Tuesdays, however it
would be a mistake to wait until after precept to start your
assignments. You may be able to ask far more meaningful questions in
precept if you already have worked on the program enough to know what
the real difficult issues are.
Finally, a note about the readme file which you must turn in
each week. Besides any problem specific information which is listed
in each week's assignment or checklist, you should use this file to
give the reader a high-level explanation of your source code and point
to any thing unusual or notable about your program (such as extra
credit or known bugs).
Checklist 1:
Shellsorting a Linked List.
The following is a checklist which provides a summary of the
assignment. This is meant only as a supplement; please read the original assignment
description.
Frequently Asked Questions:
(This is the only part of this checklist which will change during the
week.)
[Michael 12:48pm, 2/9] When we talk about the "number of comparisons"
we specifically are interested in times when you compare one key to
another key (we didn't intend to have you account for every time a
line of your code does an exchange, for instance in loop controls).
[Michael 12:48pm, 2/9] Below we say: "Make sure that a pass
of your h-sort does not use more than a constant amount of auxiliary
space or more than a constant times N time. (Note: h does not count as
a constant...this is too much)." Note, your h-sort may do many
passes. We are not requiring that your overall h-sort run in O(N)
time.
Requirements:
Possible Progress Steps:
These are purely suggestions for how you might make progress. You do
not have to follow these steps.
Write code to read the input and build a singly linked list
Write a routine to exchange two nodes of a linked list (does it
work for all cases?)
Implement bubble sort on a linked list
Implement a routine for "bubble h-sort"
(if your first
implementation uses too much space or time, how can you improve it?)
Run experiments and pick a sequence of h values for shellsort
cos226 Class Page
wass@cs.princeton.edu
Last modified: February 9, 1999