Here is my biggest contribution to Computer Science. This C function implements the Deep Thought algorithm whose existence Douglas Adams hypothesized in his radio show, The Hitchhiker's Guide to the Galaxy, in the 1970s. I wrote this in 1991 or 1992. I am not aware of any earlier implementations.
ultimate_answer_t deep_thought(void)
{
sleep(years2secs(7500000));
return 42;
}
It should be obvious that this algorithm is optimal. It executes in O(1) time, so it's impossible to improve its performance except by a constant factor, which is too trivial to matter to a computer scientist.