Tuesday, February 12, 2008

Let's Celebrate For A Little - 1K Visitors!

This is a special day for the Developer On Line-DOL- blog. Today the number of unique visitors on this blog reached more or less the astronomical amount of 1024! Before making a little fun a sincere thanks to everybody that has visited this page and specially to anybody that is subscribed on the blog's feeds. Now I think it is time to introduce better, but in short, the story behind this blog and prove why it should keep ...existing!

It started in early September with the first 'Hello World' post. Initially I planned to keep it strictly technical but it is not easy to resist broadening the subjects (sticking your nose everywhere is the right expression!). One thing I have kept is the blog being ad-free and I plan to keep it that way. It is nice to have a clean place for me to write and for you to read.

Trying to post original material is also in the 'routine'. The book stacking problem post is a good example on that. I won't say that everything here is 100% 'cotton' (this is your job!) but I confess having canceled posts that I found that had nothing new to add compared to other web sites. There is no meaning in reposting news, or republishing articles or code that is already there and is freely accessible.

Despite being around for almost 6 months, it is true that I have not been so productive. There are a total of 20 posts in this period that equal to less than 1 post per week. DOL promises to intensify the posting process and has already masterminded and executed the perfect business plan for that. I only have to wait for today's lottery and these six numbers to come up and I will be devoted in this blog for the rest of my life...!

Some statistics now. You may have noticed that this blog is using Google Analytics to measure blog traffic. It is an easy and nice way to keep track of how people find our page and how they navigate inside it. By understanding how people get to your page, you can increase blog traffic and although I do not earn money from this, it helps me in asserting the quality of the content. Here is some statistics of the countries that have visited this blog. US and Greece stands out, much ahead than other countries(UK, India etc) The main sources come from search engines in which DOL generally ranks pretty well.
DOL visitors in six months


Once again, thanks to everybody.

IMPORTANT:
PS. Now that DOL has this enormous influence, it officially endorses Barack Obama for President of the US!

If he loses, DOL invites him to Greece; we urgently need a Prime Minister and we desperately need change...

Tuesday, February 5, 2008

Google Interviews Part IV

This is the 3rd interview I had with Google. You can find the previous and the questions asked here:
* First Google interview
* Second interview

Update: Fourth Google Interview

In the 3rd interview I talked with a woman software engineer from Mountain View. As usually it lasted for about 45 minutes but there was a surprise waiting at the last question..But let's take things from the beginning.

The first question was a hard test for my memory: "How do you test your code?" This is a fair one for software engineers. But not for my style. I personally like things that are quick and dirty. For larger projects I use some of my own class libraries that employ some kind of logging, measure method execution time and so on. But saying "Well, I use my own class libraries." I thought would not be a good answer. Nor a professional one.

So talking about Java, I made the mistake of mentioning the JUnit framework. I had used for some time (long ago) but the time had passed so I had forgotten even the basics. And of course the interviewer started the questions (How the JUnit handles exception and others) To tell you a secret I had already opened in my browser a JUnit site (some kind of tutorial I guess) but this didn't help at all. So, don't do it. It will only make things worse. Trying to think logically didn't help either. The interviewer kept pushing, until I 'broke' and admitted that I couldn't answer. That was it. We moved to the next question.

All next questions were really typical, the kind you find in tech interview sites:
* "What is a Unix kernel?"
* "What is the difference between interfaces and abstractt classes?"
* "What is the difference between threads and processes?"
* "What is inheritance, polymorphism and encapsulation?"
* "What is overriding and what is overloading?"

I think there is no need to elaborate further on that. You most probably have come across these concepts and have your own mind.

Which brings us to the last question. Actually it was a puzzle including programming with handicaps, i.e. with small processor, low memory etc. The puzzle was this:
"You have 1000 integers. All are less than 1000 and greater or equal to 1. Among them, 999 are distinct and there is one that is found twice. How can you find the duplicate?" To this I gave an answer I think is optimal. The idea is simple. If you denote the duplicate number by d and the sum of all the integers by S then the following equation holds:
S-d= 499500 since S-d is the sum 1+2+3...+999 which is equal to 499500 by applying the formula 1+2+3...+n = n*(n+1)/2
Now the good thing is that we can be able to find the duplicate even we have capacity for one integer, or when reading from a stream and so on. We can optimize even if we apply modulus to the first equation: d = (S-500) (mod 1000) Now if d is equal to a positive number mod1000 then this is the duplicate, otherwise the duplicate is the negative part plus 1000. For example is 1 was the duplicate, then d=1(mod 1000) and the duplicate had to be the 1. If the duplicate was 600, then d=-400(mod 1000) so the duplicate had to be -400+1000=600. This means we do not need to have storage for integer (int type) but only the byte type is enough.

While fairly easy to grasp the interviewer had difficulties in understanding how this would work, so she asked for an example when we have 10 integers. I replied this would transform the equation to d =S-45 but then the counter question was disappointing: "How did you compute 45?" It is quite obvious however that I had to compute 1+2...+9 which is equal to 45 when applying the formula that Gauss found when he was 8. But the interviewer started computed 'by hand' the sum, adding the numbers from 1 up to 9, which left me speechless for some seconds. I mentioned that there was a formula for that but she didn't listen, still being concentrating on her computations. I didn't bother elaborating on the modulus idea since obviously would not give me any more credit.

After that, the interview had finished. I didn't ask anything, saying something like 'I have many questions but I do not wish to spend any more of your time' and we ended the conversation. In overall the last incident was really awkward. To that time I believed that all Google engineers had a good mathematical background. The engineer that I spoke with, did lack elementary skills. So in my eyes, the myth had been destroyed and it is a good advice to anybody, not bother berating himself more than he should. If you already knew the formula for the sum of consecutive integers, you have a good reason to feel more confident.

Update: Go to the last Google phone interview