[algogeeks] Re: Finding the min gap in 3 arrays

2011-06-17 Thread Dumanshu
Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jun 17, 2011 at 9:36 PM, Dumanshu duman...@gmail.com wrote: U have got 3 sorted arrays A1 A2 and A3 having m n and p elements respectively. A gap of 3 arrays is defined to be max distance

[algogeeks] Re: Mutex

2011-06-17 Thread Dumanshu
@Ankit: it seems like mutexes can work between processes. refer to http://geeksforgeeks.org/?p=9102 m i right? On Jun 17, 5:56 pm, ankit sambyal ankitsamb...@gmail.com wrote: Yes, even the threads of a single process cannot have access to each others mutex. Mutexes can be applied only to

[algogeeks] Re: Finding the min gap in 3 arrays

2011-06-17 Thread Dumanshu
of the adjacent elements are different Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jun 17, 2011 at 9:36 PM, Dumanshu duman...@gmail.com wrote: U have got 3 sorted arrays A1 A2 and A3 having m n and p elements respectively. A gap

[algogeeks] Re: MS Question

2011-06-14 Thread Dumanshu
@Sunny: what if the number is repeated multiple times? u seem to consider only the duplicates(2 times). On Jun 13, 7:36 pm, sunny agrawal sunny816.i...@gmail.com wrote: no we can take care of duplicates without any extra memory modify 2nd step of my previous solution as follows if T[a[i]] is

[algogeeks] Re: MS Interview

2011-06-10 Thread Dumanshu
Nothing is specified but lets take it as 2MB ram On Jun 10, 10:14 am, hary rathor harry.rat...@gmail.com wrote: dumnanshu  you should first mention memory size in your computer  so that i could know that how many number i can have in main memory at time -- You received this message because

[algogeeks] Re: Million Numbers

2011-06-10 Thread Dumanshu
...@gmail.com wrote: @ankit: pls explain the time complexity.. i dont think its O(log n) On Thu, Jun 9, 2011 at 11:57 PM, ankit sambyal ankitsamb...@gmail.com wrote: @Dumanshu:  In each iteration, we r removing the smallest number. If at any iteration we can't find the next

[algogeeks] Re: MS Interview

2011-06-10 Thread Dumanshu
@kunal: could u plz explan ur XOR approach by using a small set of numbers. lets say we have numbers from 1 to 5 and one number is missing. so u mean 1 XOR 2 XOR 4 XOR 5 would give me 3??? On Jun 10, 11:41 pm, Kunal Patil kp101...@gmail.com wrote: @ Dumanshu: With memory restriction also XOR

[algogeeks] Re: MS Interview

2011-06-10 Thread Dumanshu
@kunal... yeah it will work. thnx :) On Jun 10, 11:41 pm, Kunal Patil kp101...@gmail.com wrote: @ Dumanshu: With memory restriction also XOR method works.. :) In this case difference is just that you will be working with 400/ X number of files..where X is size of the RAM...just

[algogeeks] MS Interview

2011-06-09 Thread Dumanshu
Q1. I have a file in which there are supposed to be 4 billion numbers, starting from 1 to 4,000,000,000 but unfortunately one number is missing, i.e there are only 3,999,999,999 numbers, I need to find the missing number. Q2. I have an array consisting of 2n+1 elements. n elements in it are

[algogeeks] Re: MS Interview

2011-06-09 Thread Dumanshu
, subtract it from sum of first 4 billion numbers. On Thu, Jun 9, 2011 at 3:44 PM, Navneet Gupta navneetn...@gmail.comwrote: The answer to second question is simple. XORing all the elements should do it for you. On Thu, Jun 9, 2011 at 3:15 PM, Dumanshu duman...@gmail.com wrote: Q1. I

[algogeeks] Million Numbers

2011-06-09 Thread Dumanshu
Given a file containing roughly 300 million social security numbers(9- digit numbers) find a 9-digit number that isnt there in the file. You have unlimited drive space but only 2mb of RAM. Solution is as follows: In the first step, we build an array of 2^16 integers that is initialized to 0 and

[algogeeks] Re: Million Numbers

2011-06-09 Thread Dumanshu
Of Trie is high  we need (32 *(O(n)) assuming each integer is of 32 bits On Thu, Jun 9, 2011 at 4:54 PM, Dumanshu duman...@gmail.com wrote: Given a file containing roughly 300 million social security numbers(9- digit numbers) find a 9-digit number that isnt there in the file. You

[algogeeks] Re: Sudoku verification problem

2011-05-29 Thread Dumanshu
];                         } else {                                 printf(Sudoku Error: i = %d, j = %d\n, i, j);                                 return -1;                         }                 }         }         return 0; } On Sat, May 28, 2011 at 11:53 AM, Dumanshu duman...@gmail.com

[algogeeks] Re: Sudoku verification problem

2011-05-29 Thread Dumanshu
. in verify routine, if the expression evaluates to false, it mean an element is encountered which is already present in row, col and 3x3 cube. this way you an tell that the solution is wrong. hope that helps. On Sun, May 29, 2011 at 2:01 PM, Dumanshu duman...@gmail.com wrote: here

[algogeeks] Re: Sudoku verification problem

2011-05-29 Thread Dumanshu
take O(n^2) = (3*n*n) time here n is 9. On May 29, 5:10 pm, Dumanshu duman...@gmail.com wrote: no... what i mean to say is you have filled the bitmap in the process of solving the grid. The way you are  filling the bitmap is - you are taking values from the matrix and placing them in the bitmaps

[algogeeks] Re: Sudoku verification problem

2011-05-29 Thread Dumanshu
, the bitmap[] array is a local array and initialized to 0 before use. On Sun, May 29, 2011 at 5:40 PM, Dumanshu duman...@gmail.com wrote: no... what i mean to say is you have filled the bitmap in the process of solving the grid. The way you are  filling the bitmap is - you are taking values

[algogeeks] Sudoku verification problem

2011-05-28 Thread Dumanshu
Given a n by n matrix. Suggest an algorithm to verify its correctness given a configuration. User can enter numbers only between 1 to n. I need this in 2 ways - 1. for the n by n matrix, suggest an elegant way for validating it. 2. suggest a data structure for this sudoku so that the structure

[algogeeks] Re: Google Interview Question

2011-05-28 Thread Dumanshu
I think he means to edit the comparison function to get the order. so at a time only 2 elements are compared. On May 28, 7:51 am, Logic King crazy.logic.k...@gmail.com wrote: @sunny it will work fine if you have 2 numbers only...but what about the list...3..4 or 5..or morethen the possible

[algogeeks] Find min after rotating an array

2011-05-28 Thread Dumanshu
Find an elegant way of getting the minimum value in a sorted array but it has been rotated by some number. say u had the array as 4 , 5, 6, 7, 8,9 and u rotate it by 2. u get 6,7,8,9,4,5. Now u have to find minimum number in this modified array. -- You received this message because you are

[algogeeks] Re: Find min after rotating an array

2011-05-28 Thread Dumanshu
a [ ],int low, int high) {     int mid = (low+high)/2;     if(a[mid]a[mid+1])           return (a[mid+1]);      if(a[low]a[mid])            return (get_pivot(a,low,mid-1));      else            return(get_pivot(a,mid+1,high)); } On 5/28/11, Dumanshu duman...@gmail.com wrote: Find

[algogeeks] Re: [brain teaser ] Mystery Puzzle Servant Wish 25 may

2011-05-25 Thread Dumanshu
hmm... u r right. my mother should see my child in a very big swing made of gold and studded with diamonds :D On May 25, 12:56 pm, vaibhav shukla vaibhav200...@gmail.com wrote: he should wish that my mother could see his grand child playing with his very rich grand-father On Wed, May 25, 2011

[algogeeks] Re: [brain teaser ] Mystery Puzzle Servant Wish 25 may

2011-05-25 Thread Dumanshu
assume master is someone with supernatural powers... because nothing is specified :) actually this puzzle dates back to some age of gods and goddesses... Indian Mythology. On May 25, 12:50 pm, ArPiT BhAtNaGaR arpitbhatnagarm...@gmail.com wrote: master can give only monet so obviously money On

[algogeeks] Re: Facebook Interview Question from glassdoor

2011-05-23 Thread Dumanshu
I didn't get the question actually. I have copied the post(the question). but i dont think for 12, 36 can be the answer. We have to go for the permutation of the telephone number i guess after substituting for each number the corresponding set of alphabets. The question given is - Given a

[algogeeks] Re: Another SPOJ Problem -SIGSEGV -- Need Help

2011-05-23 Thread Dumanshu
I want to discuss the solution in C language. I want to test my file using gcc compiler. For C the best solution is 5 chars. Any ideas about that?? On May 23, 7:23 pm, saurabh singh saurab...@gmail.com wrote: Using the asm construct of c.. Though i did this problem in native asm and my

[algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Dumanshu
Could u plz elaborate? about the quotient?? On May 22, 1:50 pm, ankit sambyal ankitsamb...@gmail.com wrote: Solve it using shift operator   here is the crude algo :  the procedure for the division algorithm, given a dividend and a divisor would be to left shift (multiply by 2) the divisor

<    1   2