Sunday, November 26, 2006

My standard problem

Hi,

This is one of the problems that I always wished to set as an example to illustrate the orientation in thinking while solving a software problem.

Ok here is the problem

I have a list of consequitive numbers ( example : b/n 50-60). They are arranged in an unsorted manner.
One of the number in the range is missing.

You have to identify that number. The solution should be in O(n).

I have used the problem as an example a hundred times. So people who have been present during these session can restrain themselves. Others hack into your brains.

Rahul.

3 Comments:

Blogger Shivanand PB said...

can this be a solution ?
no you want =(60*61)/2 - (50*51)/2

8:14 PM  
Blogger Girish Kolari said...

I think the answer is AP (arithmetic progression)

4:31 PM  
Blogger Rahul said...

both of you are right.
All we have to do is get the expected sum and the real sum and bingo , we have the answer

6:17 PM  

Post a Comment

<< Home