Nostalgia…..and a long awaited comeback

Got bored, wanted to test my memory (and latent C skills):

#include 

typedef struct node {
        char* data;
        struct node* next;
}* NODE;

int main()
{

        NODE root = NULL;
        NODE tail = NULL;

        root = (NODE) malloc(sizeof(struct node));
        tail = (NODE) malloc(sizeof(struct node));

        root->data = "hello";
        tail->data = "world";

        root->next= tail;
        tail->next = NULL;

        // display the contents of the linked list
        NODE cur = root;
        for(;cur != NULL; cur= cur->next)
        {
                printf("%s ", cur->data);
        }

        free(root);
        free(tail);

        printf("\n");

        return 0;
}

And it worked. First time around. Nice! 😉

Cats and Parallelism

As far as I can recall, it was the first grade and there was this question that was staring at me from the book:

“If one cat can catch one mouse in one minute, how many
minutes does it take for three cats to catch three mice?”

Simple, is it not? Of course we all know that the answer is one minute. To someone grokking the basics of mathematics and logic, not so apparently easy. The fact is that it took me quite a bit of time to realize that it was not a simple case of arithmetic correspondence to (wrongly of course) equate three cats catching three mice in three minutes! What I realized after some ponderous consideration is that all the three cats were working in “parallel” to catch the three mice!

That then was my first lesson in parallelism.