Log in

No account? Create an account

Previous Entry | Next Entry

I got my computer science test back ("Midterm 1", which seems like an oxymoron), and it was good. 100% good. Wai.

The only thing he even suggested was wrong was actually right. The code below was to compute the intersection of two linked lists, a and b, returning the result in dest:

void join(List *a, List * b, List * dest) {
    ListNode *pA=a->header(), *pB=b->header();
    while(pA && pB) {
        if(pA->x == pB->x) {
        if(pA->x <= pB->x) {
            pA = pA->next;
        if(pB->x <= pA->x) {
            pB = pB->next;
He thought that the use of "<=" was incorrect--his exact comment was "cannot be equal anymore". But if you look at it, that isn't true (I didn't use "else if"), and in fact that's central to the program's structure.

The cool thing was, I did not study for this test. I did not read the textbook, or pay attention in class. Moreover, one of the questions involved implementing a queue, something I've never actually done before, but I had no trouble with it. I also pulled my answers on the final questions (some stuff about hashing--English answers, not code) out of my ass, but apparently my ass knows a lot about hashes, because they were all correct.


( Read 3 comments — Leave a comment )
(Deleted comment)
Mar. 12th, 2004 12:51 am (UTC)
Meanwhile, I barely passed my first test in Unix. I forgot the command to change the default mask for newly created files, I didn't know the difference between diff and comp, and I didn't know what the command for looking up files was. -_- (It was a written test, by the way, with questions like "what does this command do" and "what would you type to do this".)

Not too good, considering I'm re-taking the class... I should start doing the homework. And stop telnetting to nethack.alt.org in a second shell during classes.
Mar. 12th, 2004 10:04 am (UTC)
Do you do any Real Work(tm) in Unix? If not, try to find some--that's by far the best way to learn.
( Read 3 comments — Leave a comment )