For the real techies …

Look at the following code. Its a simple binary search algorithm that has been tought during the first semester of any Computer Science degree. Its the same code which is available in the classic Programming Pearls book for the past 20 years and in the Java library for the past 10 years. Now, can you find a bug in this code?


public static int binarySearch(int[] a, int key) {

int low = 0;
int high = a.length – 1;
while (low key)
high = mid – 1;
else
return mid; // key found
}
return -(low + 1); // key not found.
}

Don’t worry. I’m not here to prove that I’m technically superior to you, because neither did I find the bug. But someone else did! Check this!

ஹூம். பாட்டு எழுதி பேர் வாங்கறவங்க சில பேர். அந்த பாட்டுல குத்தம் சொல்லி பேர் வாங்கறவங்க சில பேர்.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: