Re: [algogeeks] Re: Median of two sorted arrays of different sizes

2013-06-11 Thread Abhirup Ghosh
How is this code dealing with the scenario where two arrays have common number. For example where two arrays are same. A[] = {1,2,3,4} and B[] = {1,2,3,4}. Here the median position is not (4+4)/2 rather it is 4/2. On Sun, Jun 9, 2013 at 3:12 PM, rahul sharma wrote: > @doncan u plz explain t

Re: [algogeeks] size of array

2013-01-31 Thread Abhirup Ghosh
When malloc allocates memory it assigns a size field in the header to indicate the size of the memory it allocates at a stretch. Can we not use this information effectively? On Jan 31, 2013 11:44 PM, "Piyush" wrote: > it will always work if array is statically allocated > Not if dynamically allo

Re: [algogeeks] decimal to binary..c code....

2012-02-01 Thread Abhirup Ghosh
I think you have to think about the manual way of doing it - how to handle the integer part and decimal part. You can find this in any standard book. Then try out the algorithm. On Mon, Jan 30, 2012 at 12:26 AM, Rahul Kumar wrote: > ur subject is decimal to binary but in content u have written

Re: [algogeeks] Android Project

2012-02-01 Thread Abhirup Ghosh
If you have Android sdk setup then you can find samples in that only. If you haven't done that please find necessary information in http://developer.android.com/index.html - Abhirup On Tue, Jan 31, 2012 at 5:20 PM, saurabh singh wrote: > > Saurabh Singh > B.Tech (Computer Science) > MNNIT > blo

Re: [algogeeks] Longest SubSequence with Sum < K

2010-08-31 Thread Abhirup Ghosh
If the subsequence is not to be continuous then sort the given array. O(nlogn) and then go on adding from the least element until the sum gets >= k and then denote the array elements till the previous one as the set of desired elements. O(n) Total complexity O(nlogn). - Abhirup On Tue, Aug 17,

Re: [algogeeks] microsoft interview(numbers)

2010-07-06 Thread Abhirup Ghosh
We can build a wrapper object having two fields one th actual integer in the array and the count o the integer in the given array. Then build an array of those objects. Range of this array can be found easily by finding max and min of the array in O(n) time. We can build the auxiliary array in O(n)

Re: [algogeeks] lru cache

2010-07-03 Thread Abhirup Ghosh
I think this can be implemented with queue data structure. Whenever an element is used, remove it from the queue use it and then again insert it in the queue at the back. So the front element in the queue is the least recently used one. -Abhirup On Fri, Jul 2, 2010 at 10:23 PM, jaladhi dave wro

Re: [algogeeks] Finding Duplicates in Random Array

2010-07-03 Thread Abhirup Ghosh
; > > On Fri, Jul 2, 2010 at 3:29 PM, Abhirup Ghosh wrote: >> >> 1. (1) Maintain a hash table and insert the elements in the table when >> passing through the array. And if there is a collision then that >> element is a duplicate element in the array.Time - O(n) and the s

Re: [algogeeks] recurring number

2010-07-02 Thread Abhirup Ghosh
Can you please elaborate on the solution you have with auxiliary array? On Fri, Jul 2, 2010 at 3:53 AM, jalaj jaiswal wrote: > > we are given with  Numerator and Denominator. After division we might get a > recurring decimal points float as the answer. > For example 23.34563456 ... > return 345

Re: [algogeeks] microsoft

2010-07-02 Thread Abhirup Ghosh
I think those two sensors should not be exactly opposite to each other to make the decision meaningful. On Fri, Jul 2, 2010 at 11:58 AM, Jitendra Kushwaha wrote: > I think two sensors beside one another is enough to  find the direction of > rotation. > At some time both will be sensing the same

Re: [algogeeks] Finding Duplicates in Random Array

2010-07-02 Thread Abhirup Ghosh
1. (1) Maintain a hash table and insert the elements in the table when passing through the array. And if there is a collision then that element is a duplicate element in the array.Time - O(n) and the space is O(n). (2) Duplicate is detected by the above process. Then it can be easily removed. I ca

Re: [algogeeks] Re: O(n)

2010-06-28 Thread Abhirup Ghosh
n>max then max = n; > > so the range would lie between min and max.. > > correct me if I am wrong.. > > On Mon, Jun 28, 2010 at 2:20 PM, nisha goyal > wrote: >> >> @abhirup: range is required in counting sort how can you decide that?? >> please elabor

Re: [algogeeks] Re: O(n)

2010-06-27 Thread Abhirup Ghosh
We can sort the array in O(n) time using counting sort. And then take the difference of consecutive elements in O(n) time to get the minimum one. -Abhirup On Mon, Jun 28, 2010 at 10:36 AM, Jagadish M wrote: > In the general case, we can reduce Element-Distinctness(ED) problem to > this problem