Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALGORITHM


  How regular expression works

Rob Pike wrote 30 lines of codes to realize a simple regular expression matcher in his book The practice of Programming. This piece of code is really cool. Let's take a look at the code.Meaning of different characters.CharacterMeaningcGeneral character.Match any single character^Match start of a string$Match end of a string*Match zero or many occurrences of a character/*match :Test the regexp in text*/int match(char* regexp,char* text){    if(regexp[0] == '^')        return matchhere(regexp+1,text);     do{ /*Check the strin...

3,219 0       C REGULAR EXPRESSION IMPLEMENTATION ROB PIKE


  A boolean value interview question

Someone asked a question on StackOverflow, he was asked an interview question. The question is : Given 3 boolean variables a, b, c, return true if at least 2 out of the 3 are true. He gave the solution as follows :boolean atLeastTwo(boolean a, boolean b, boolean c) {    if ((a && b) || (b && c) || (a && c)) {        return true;    } else {        return false;    }}Then the interviewer asked him to improve the solution given and ma...

6,603 0       RETURN EXPRESSION BOOL CONDITIONAL


  Google search engine algorithm change history

Recently, Google had a major adjustment on its search algorithm: Users can directly see answers to the searched question on the top of the page.There are billion of search requests each day on Google. There is no doubt that the algorithm will become the subject of discussion. Last year, Google did an adjustment to its search algorithm every 17.5 hours in average. We all experience the change of the algorithm. Following information chart summarizes the major changes of Google search algorithm since 1998.From the above table we can see several major search algorithm improvements:March 1998...

6,127 0       GOOGLE HISTORY SEARCH ENGINE GOOGLE+


  Solving easy problems the hard way

There’s a charming little brain teaser that’s going around the Interwebs. It’s got various forms, but they all look something like this:This problem can be solved by pre-school children in 5-10 minutes, by programer – in 1 hour, by people with higher education … well, check it yourself! 8809=67111=02172=06666=41111=03213=07662=29313=10000=42222=03333=05555=08193=38096=57777=09999=47756=16855=39881=55531=02581=?SPOILER ALERT…The answer has to do with how many circles are in each number. So the number 8 has two circles in its shape so it coun...

3,790 0       PROBLEM SOLVING


  How Speeding The "Most Important Algorithm Of Our Lifetime" Could Change This Modern World

Math breakthroughs don't often capture the headlines--but MIT researchers have just made one that could lead to all sorts of amazing technological breakthroughs that in just a few years will touch every hour of your life. Last week at the Association for Computing Machinery's Symposium on Discrete Algorithms (SODA) a new way of calculating Fast Fourier Transforms was presented by a group of MIT researchers. It's possible that under certain situations it may be up to ten times faster than the current way we do these. At this point you are probably wo...

2,634 0       FFT FAST FOURIER TRANSFORM SPEED-UP


  Dividing any number By 9, 90, 900 and so on

Thetechnique for Dividing any number by 9 mentally is simply to reduce a complex divisionto a very simple addition. The technique can be applied from both ends i.e. from right-most digit or from left-most digit. Dividingby 9 into a mixed number from right-most digit uses the Divisibility Rules for9:1.     First, add all the digitstogether and divide by 9, keeping in mind the whole number and the remainder.2.     Write the remainder over 9, thisis the fraction part of the answer. (Make sure the fraction is in simplestform.)3.     Add a...

6,162 0       ALGORITHM 9 90 DIVISION


  Overlap Detection

How does one detect when two strings overlap? In the case below, the four-letter suffix of string 1 matches the four-letter prefix of string 2.1: "Fire at Will"2: "William Riker is number one"Sometimes there are several matches; finding the longest is not always straight forward.1: "Have some CoCo and CoCo"2: "CoCo and CoCo is here."2: "CoCo and CoCo is here."2: "CoCo and CoCo is here."The naïve solution is to take ever smaller substrings of each string, compare them, then bail out when the first match is found. This is quick ...

7,052 0       PYTHON IMPLEMENTATION STRING OVERLAP DETECTION


  Bytes Matter

I love to profile applications, because I always learn something that surprises me.Initial Profiler Surprise: Client SideCase in point, I was recently profiling our Android application, the Famigo Sandbox. This app sends a lot of data back and forth with our API, as we try to determine which of the apps on your phone are safe for your kids. I always assumed that, if app performance suffered during some of the chattier features, it was probably due to slow cell reception.The profiler told me that I was wrong; the tran...

2,669 0       BYTE LOW LEVEL OPERATION IMPORTANCE