|
|
Recent Announcements:
-
-
9 May The unit tests used to grade PS8 are
available on the Zoo in /c/cs223/assignments/ps8/unittests.
-
28 Apr. Some hints/clarifications for
PS9:
-
To get exact copies of the test data files in
the assignment directory, use the cp
linux command from a command shell on the Zoo
rather than reading the file with your browser
and then saving it. cp will copy the
bytes exactly; other methods may add gratis new
line characters or otherwise modify the file.
Recall that the path name to the assignment
directory is
/c/cs223/assignments/ps9.
-
When serializing a leaf node of the Huffman
tree, you will need to write out the 8 bits of
the byte corresponding to the leaf. While there
are many ways of doing this, one way is to turn
those bits into a Bitstring using the function
newBitstringFromBytes(). This takes
two parameters: the number of bits you want and a
pointer to the first byte in an array of bytes
whose bits you're after. In this case, you will
want all 8 bits from a single byte
b, so the parameters would be
(8, &b). The Bitstring can then
be written to the output file using
putsObitstream().
-
Section 5, paragraph 8(a) in the problem
assignment about how to handle an empty file is a
bit confusing. All files are encoded by bit
streams as written by Obitstream and read by
Ibitstream. The empty plaintext file is encoded
by the empty bit stream, that is, the bit stream
consisting of no bits at all. However, an empty
bit stream, as written to a file by Obitstream,
will not result in an empty file. Rather it will
result in a file containing the single byte 0x00.
When this file is read back using
Ibitstream, the first call to
getIbitstream() will return EOF.
How do you write an empty bit string to a
file? Simple. Don't write anything! Open an
Obitstream and then close it without making any
calls to putbObitstream() or
putsObitstream().
-
Question: "I wrote to an Obitstream but my
file was empty. Why?"
Answer: You probably failed to open and close
the bit stream and underlying byte stream
correctly.
To use an Obitstream to write a file, you must
first open the file for writing using
fopen(). Then use
openObitstream() to open a bit
stream on the byte stream returned by
fopen().
When you are done writing, you must
close both streams. First call
closeObitstream() to close the
Obitstream. (This is when the padding and final
count byte get written to the file.) Then call
fclose() to close the underlying
byte stream.
-
24 Apr. I added a third test file to the
PS9 assignment
directory, two.in,
along with its Huffman encoding two.hz.
This is a very simple file consisting of
just two bytes, 'a' followed by 'b'. In hex, these
bytes are 0x61 and 0x62. The encoded file is 4 bytes
long. You can see those bytes using od -tx1
two.hz . If your hufenc and
hufdec commands do not work correctly on
these very simple files, you can't expect them to
work on more complicated files, so start here with
your debugging. These files have the advantage that
it's not difficult to construct the Huffman tree and
its serialization by hand, so you can actually figure
out what the bits should be.
-
24 Apr. I just posted today's lecture notes
and demo. Also, I put two files along with their
Huffman encodings into the PS9 assignment
directory. The plain text file names have
extension .in; the Huffman-compressed
versions have extension .hz.
-
24 Apr. Two announcements:
-
The extra-credit Problem set 10 (.pdf) is
available. It is due before midnight on Monday,
May 5. Unlike previous problem sets, this
deadline is firm and there will be no
extensions.
This problem set is optional. It will be
graded like the others, but only the best 9 (out
of 10) problem sets will count towards the final
grade. It is intended primarily for people who
want a way to make up for work missed earlier in
the term, but of course anyone is welcome to try
it.
-
The final
examination will be held in room ML 211,
not in our regular classroom. The date
and time are Thursday, May 8 at 2:00
pm as previously announced.
-
20 Apr. Two announcements:
-
PS9 Deadline Extension. Due
to popular demand (and people's busy end-of-term
schedules), I am extending the deadline for PS9
to before midnight on the last day of classes,
which is Monday, April 28.
-
There will be an extra-credit PS10 due on the
last day of reading period, Monday, May 5. The 9
best problem sets (out of 10) will count towards
the final grade. If you did well on the first 9
problem sets, there is little to be gained
(pointwise) by doing PS10, but if you got a low
grade on one of the earlier sets, this is your
opportunity to make up the missed work and raise
your grade.
-
20 Apr. There is a bug in the code I
furnished for Problem set
9 in the file bitstring.c.
The first line of code in the function
streamWriteBitstring() should be
const int maxwrite =
(1<<(8*sizeof(byte)));
In other words, maxwrite should have
the value 256, not 2. (It's fixed on the web site
now.)
In fairness, I should point out that both this
function and the function
fwriteCodetable() that uses it are left
over from previous code. Neither is used by the
furnished pfxenc nor pfxdec
commands, nor is either needed for the code you are
to write. A previous (non-buggy) version of
streamWriteBitstring() was used in
generating the sample code table
sample-code.pfx , but the file
representation you are to use for the Huffman code is
a serialized code tree as described in the problem assignment, not a code
table. The only reason I can think why you might want
to write your Huffman code to a file in the form of a
code table would be in order to test it with
pfxenc and pfxdec during
debugging, but it is not necessary to do so.
-
15 Apr. Notes and
demos for the past two lectures are now
available.
-
14 Apr. Problem
set 9 (.pdf) is available. It
is due before midnight on Tuesday, Apr. 22.
-
6 Apr. I put a file testdata.txt
into the PS8
assignment directory that contains some sample
Hamming code (data, codeword) pairs. You can use this
to check your understanding of the Hamming code and
bit-numbering conventions in the PS8 assignment as
well as for testing your code once it's written.
Please see the readme file for
an explanation of the file format.
-
3 Apr. Two announcements:
-
31 Mar. PS7 Deadline
Extension. Several people have asked for an
extension for PS7, which was originally due tomorrow.
I have decided to extend the deadline to Friday,
April 4. Submissions will be accepted for up to four
days past that date (through Tuesday, April 8)
without prior approval, subject to the usual late
penalty of 5% per day late after April 4.
-
12 Mar. Problem
set 7 (.pdf) is available. It
is due before midnight on Tuesday, Apr. 1.
-
5 Mar. Lecture notes and demos from
Tuesday's lecture are available here and linked on the lecture notes page.
-
5 Mar. The unit test files that were used
for grading PS4 are in the PS4 assignments
directory in the subfolder unittests.
-
5 Mar. The version 2.10.6 of
gtk on the Zoo has a bug in the file
/opt/gnome/include/gtk-2.0/gtk/gtktextbuffer.h
that causes a pile of warnings to appear saying "ISO
C restricts enumerator values to range of 'int'".
This has been fixed in newer versions. As a
workaround, I suggest removing
"-pedantic" from CFLAGS in
your Makefile for PS6. That will
suppress these warnings but not more serious
ones.
-
2 Mar. I've posted a new handout, Using const in C
(.pdf). This
supplements the brief mentions of const
that have been made in class.
-
2 Mar. Lecture notes and demos from last
Thursday's lecture are available here and linked on the lecture notes page.
-
1 Mar. Two announcements regarding Problem
Set 6:
-
Bug in controller.h: The
controller code that was distributed as part of
the PS6 assignment failed to cause a redraw of
the Hex board after getting control back from the
undoGame() and
redoGame() functions, even when they
returned true to signal that a
redraw was needed. This would have made it seem
like your code for Undo and Redo was not working
even when it was. The problem is fixed now, but
it would have presented difficulties to anyone
who tried to work on the assignment. Please be
sure to copy over the corrected code for controller.c
from the PS6 assignment
directory before continuing to work on
the assignment.
-
Deadline
extension I like to give
everyone a full week to work on my assignments.
Since a week from today falls during the Spring
recess, PS6 is now due before midnight on the
first day after the recess, Monday, March
24.
-
28 Feb. Problem
set 6 (.pdf) is available. It
is due before midnight on Thursday, Mar. 6.
-
26 Feb. I've corrected a small error in
version 2 of the handout, Overview of the C
Storage Model (.pdf). The test to see
if a pointer is NULL used != where it
should have used ==.
-
24 Feb. I'm glad to see that people are
reading the handout on Integer Types in
C (.pdf). The just-posted
version 2 corrects a small error in the line above
equation (2). When the sign bit is negative, then
v = u -
2n-1. The original version had
the two terms reversed, giving v the wrong
sign.
-
23 Feb. I produced a graphical user
interface (GUI) Hex Game program and placed it in the
PS5 assignment
directory in the folder gui. This
folder contains a GUI-based reference program called
greference. It also contains files and
instructions to allow you to link my code with your
own version of hexcode.o. This will give
you another means of testing the correctness of your
own code as well as providing a more satisfying
application of your code than the required
game.c simulator. See the README file
for more information.
-
21 Feb. Lecture notes and demos from this
week are available here and
linked on the lecture notes
page.
-
21 Feb. As announced today in class, the
late penalty for PS5 has been waived, but the
deadline has not been extended. This means that you
can submit during the usual 4-day grace period for
full credit, but submissions after that time
(midnight Monday) will not be accepted without prior
approval from me.
-
21 Feb. Andi will hold extra office hours
today from 4-5 pm.
-
19 Feb. The reference program for PS5
creates a board of size 11 with bounding box origin
(lower left corner) at point (0,0) and hexagon size =
10.0. Your game.c should do the
same.
-
19 Feb. I just fixed another problem with
the reference program in the PS5 assignment
directory. A break statement was
missing at the end of one of my switch
cases, causing spurius "point off board" messages to
print.
-
19 Feb. Lecture notes and demos from last
week are available here. Links
to them have been added to lecture notes.
-
19 Feb. The reference program in the
PS5 assignment
directory was incorrectly computing the right
edge of the bounding box. The version I just put
there should fix this problem.
-
18 Feb. I've posted a new handout, Modules and Separate
Compilation (.pdf). This summarizes
material presented in the lectures about modules,
interface and implementation files and what goes in
them. It also describes how to use make
and describes some testing and debugging methods.
-
17 Feb Three announcements regarding the
midterm:
-
Reminder: The midterm exam will be on
Tuesday, February 26 at the
regular class time and place.
-
The TA's will hold a review session for the
midterm on Sunday, February 24,
7-9 pm in room AKW 100. This will be instead of
the regularly scheduled office hours that day. If
for any reason the room is not available, then
try AKW 200, AKW 400, and AKW 500 in sequence. At
least one of them should be free on a Sunday
evening.
-
If you haven't yet gotten your ID card
validated for after-hours access to AKW and the
Zoo, please do so before next Sunday. (See Lori
in the basement of AKW.) Otherwise, you can
expect trouble getting into the building for the
review session.
-
16 Feb. Correction to PS5 handout: The due
date is Thursday, Feb. 21. Version 2 of the assignment
(.pdf)
corrects this error.
-
15 Feb. The other PS3 tests are now
available in the folder unittests/other_tests.
-
15 Feb. I've posted the strictly correct
unit test files that were used for grading PS3 in
case you want to try your program on them to see what
the grading comments are referring to. They're in the
PS3 assignments
directory in the subfolder
unittests/strictly_correct.
-
14 Feb. Problem
set 5 (.pdf) is available. It
is due on Thursday, Feb. 21, before
midnight.
-
-
9 Jan. A final examination will be given at
the officially scheduled time, Thursday, May
8, 2:00 pm (room to be announced).
Please take this into
account when making your end-of-term travel plans. I
do not plan to give an early exam for the
convenience of those who want to leave campus
early.
-
[Old Announcements]
|