This page does not represent the most current semester of this course; it is present merely as an archive.
This is the Homework associated with the data lab. Most of the text from the lab applies here too.
Do this on your own. Do not work with others. Do not work with a tutor, the web, etc., on the assignment itself.
If you get substantive conceptual help from a TA, instructor, friend, website, etc, please note that in a comment:
/*
* Luther Tychonievich (lat7h)
*
* I found http://dx.doi.org/10.1109%2FIEEESTD.2008.4610935 very useful
* Jim (a TA) was nice to me in office hours
We will grade on correctness. You will know what the grade is before you submit: simply run ./driver.pl
.
minusOne: If you are stuck, look up what each of the allowed operations does.
negate: This is in the textbook.
implication: a
implies b
is true if either a
is false or b
is true.
bitParity: If you xor half of a number with its other half, the half-sized result has the same parity as the original.
isAsciiDigit: Consider how you would solve ≤ and ≥.
multFiveEigths: See section 2.3.7; it's not the full answer, but it is a good hint.
howManybits: This one is harder than the others. To start, if negative, flip the bits (e.g., -3 = 0b11...101
takes the same number of bits as 2 = 0b00...010
). Zero is a special case (answer 1, not 0). The main logic of the most efficient solution we've seen sets each bit of the answer based on if any bits in a region of the input are 1s. For example, if any bit in the top half of the number is a 1, then the answer is between 16 and 31, and all numbers between 16 and 31 have a 1 in the 16s-place-bit (i.e. 0b00...001####
).
Have trouble getting it to work on your machine? Try the following:
linux> sudo apt-get install libc6-dev-i386 gcc-multilib
datahw-handout.tar instead of datalab-handout.tar. Note: This file will become available on 2015-01-22.
The problems in bits.c are different.
The “Beat the Prof” page has been reset for the homework problems.
Still no credit (but also no cost): ./driver.pl -u "Your Nickname"
; if you come in top you get bragging rights.
Nicknames are limited to 35 characters and can contain alphanumerics, apostrophes, commas, periods, dashes, underscores, and ampersands. You can submit as often as you like. Your most recent submission will appear on a real-time scoreboard, identified only by your nickname. You can view the scoreboard by pointing your browser at
Wilkes is just some computer we have, and it might not be up all the time. If you can't see it, try again an hour later.
Still submit on the submissions page. You can submit multiple times if you like.