1. Extract your priority queue class from its cushy notebook home into a .py file and test.
2. Create a comparison function comparing two strings, A
and B, that works as follows:
if their lengths are different, then the one with the smaller length is smaller
if their lengths are equal, then the one that comes "lexically first" is
smaller. For instance, "A" < "b", and "B" > "a" (this is also known
as case-independent sorting, or dictionary-order).
3. Create a complete program called queue_test.py
, which includes your priority code, that reads an input file and writes an
output file, and can be called like:
$ python3 queue_test.py input-filename
output-filename
4. The input file will consist of a sequence of commands, each command on a line
by itself. There are 3 types of commands:
push some-word
pop
tolist
5. The program should instantiate your priority-queue,
and then open the input file and read and execute each command, one after the
other.
push Fred
will push the word Fred onto the queue,
pop
will pop the smallest word off the queue (and will be thrown away)
tolist
will be the last command, and will write out the result of your queue's
tolist() method onto one comma-separated line in the output file.
6. Example. Suppose the input file contained the
following commands:
push Fred
push abe
push MARY
pop
push beth
push George
pop
push harry
tolist
then the output file should contain the single line:
Fred,MARY,harry,George
7. Test, and submit to the homework server slot: "Queue tester" and test with its program-tester.