Interview with God – beautiful message!

One of my friend forwarded me an email which subject "Interview with God". Interested by the subject line, wanted to read that email completely. Read it. Awesome one! Searched in Live search for "Interview with God"! Got this wonderful website.

http://www.theinterviewwithgod.com/viewmovie.html

Praise the Lord! Trust in God, you will always win.  I do remember coming through this verse somewhere, not sure where it is.

"Don’t ask God for the things you want, always ask God for things you DESERVE"

If you didn’t get the thing you asked for, God has certainly more than that which you DESERVE.

Prepaid Computer – like prepaid mobile?

Heard about prepaid mobiles, what is a prepaid PC? I know you must be thinking hard about this. Simple. Microsoft FlexGo presents Pay-As-You-Go computers – prepaid computers! This gives the flexibilities for the users in emerging markets like India, China, etc where people work with a very less paychecks, but wish to own a Vista powered PC.

Check this site http://www.microsoft.com/whdc/flexgo/payasyougo.mspx for more details about prepaid PCs.

This is what Frederico Trajono thinks about this:

"Sometimes great ideas are not feasible in practice, but the pay-as-you-go PC project proved quite the contrary. All the machines that we made available for sale in this initial stage were sold. In some cases we even had waiting lists! Even more important for the feasibility of the project, the level of PC usage by clients is meeting our initial expectations."

PCPrepaid

Free Software?

Robert McLaws talks about Free software in his blog post here. Wonderful post. He just said the truth of life. How will be the software engineers will be paid if the world continue to support Free Softwares? To some extent, free softwares should be there. I mean, to the extent of getting some goddies after you buying an expensive product in a showroom. That is okay with me. But that expensive product which is being developed after putting a lot of man hours of work, should be sold, not thrown as free.

Write softwares, Sell them, don’t throw them for free, if you feel you had put a lot of efforts / man power into the development. Enough said! Comments welcome!

Microsoft also support the idea of OpenSource to the applications developed.

http://www.codeplex.com is a wonderful site where you can see a lot of activities / initiatives / development happening on OpenSource softwares / utilities.

Find the missing number with minimum complexity

Problem

You have 2 arrays, one array A contains 20000 nos and all numbers are distinct and are in random order. Second array B contains 19999 numbers and it is the subset of the array A. Find the number which is in A but not in B.

Answer

Use XOR and compexity is O(n)

@algo

Let arr1 and arr2 be the arrays with 20000 and 19999 elements respectively.

int temp=0;

for(int j=0;j<20000;j++)
    temp^=arr1[j]; ///Is O(n)

for(int j=0;j<19999;j++)
   temp^=arr2[j]; ////Is also O(n)

Now temp contains the missing element.

PS : I got this problem / algorithm from one of my friend. And here is my sample C# code which verifies it, I have used the arrays of sizes 5 and 4:

using System;
namespace ConsoleApplication1
{
class Program
{
 static void Main(string[] args)
 {
   int[] arr1 = { 1, 2, 3, 4, 5 };
   int[] arr2 = { 1, 3, 4, 5 };
   int temp = 0 ;

   for (int j = 0; j < 5; j++)
      temp ^= arr1[j]; ///Is O(n)

   for (int j = 0; j < 4; j++)
      temp ^= arr2[j]; ////Is also O(n)

   Console.WriteLine(temp);
   Console.ReadKey();
 }
}
}

The output is : 2