0;
}
Complexity O(n)
Cheers,
Ankit Sinha
On Thu, Dec 1, 2011 at 4:58 PM, sourabh sourabhd2...@gmail.com wrote:
@atul...
thanks dude for ur thorough screening of the algo and pointing out the
mistakes... I think that's y its always said that until and unless we
don't turn an algo to a working
Only possible best solution seems to be sorting the array using median
selection algorithm ( a varient of quicksort) and then comparing to
find the elements.
Cheers,
Ankit!!!
On Thu, Nov 24, 2011 at 11:32 AM, kumar raja rajkumar.cs...@gmail.com wrote:
In the given array all the elements occur
; i 9; i++)
printf([%d], a[i]);
system(PAUSE);
return 0;
}
Please comment.
Cheers,
Ankit Sinha
On Sat, Sep 24, 2011 at 4:10 PM, malay chakrabarti m1234...@gmail.com wrote:
dutch national flag problem :)
On Sat, Sep 24, 2011 at 3:45 PM, Dheeraj Sharma
Algo:
1. Sort the array
2. modify binary search on the set comparing average of both the set.
3. if aveage (start, mid) average (mid , end) then go to left sub
set else right subset.
This could lead to solution in o(nlogn) time. Please comment futher!!
Cheers,
Ankit Sinha
On Sat, Aug 27
. If there are N numbers in the file, the work is O(N * log k).
Dave
On Mar 23, 11:22 pm, Ankit Sinha akki12...@gmail.com wrote:
Guys,
My intention was to understand how to manage max heap of k size into
memory. Means we have millions of numbers that we can't load into RAM
then how in the very first go
Guys,
My intention was to understand how to manage max heap of k size into
memory. Means we have millions of numbers that we can't load into RAM
then how in the very first go we going to load only k size and how
will track of rest numbers. Can anybody code it? Do we need file to
store million
Asked in Amazon interview..
Find the first K smallest element from 1 million sized array . Assume
your ram memory is so small that it cannot accommodate all 1 Million
element at once.
Guys provide your inputs on the same...
Thanks,
Ankit
--
You received this message because you are
Hi,
Here is the code to do this using Bsearch in o(logn) time.
int BsearchElemEqualIndex (int *a, int start, int end)
{
int mid = (((end - start) 1) + start);
if (a[mid] == mid)
return a[mid];
else if (a[mid] != mid)
{
if (mid ==
should be the answer for this:
if A={0,1,2,4,5}
0 or 1 or 2
On Thu, Mar 3, 2011 at 6:26 PM, Ankit Sinha akki12...@gmail.com wrote:
Hi,
Here is the code to do this using Bsearch in o(logn) time.
int BsearchElemEqualIndex (int *a, int start, int end)
{
int mid = (((end - start) 1
@rahul, they are right as binary search is made on sorted array only.
think of array as
0,2,3,8, 10, 12, 14., 15. here a[mid ] = 10 mid(4) hence next search
should happen between 0 till 4 subarrray.. In my code the input array
is also not correct as it is not a sorted array and that's why I made
It is funny but right input is as mentioned earlier to rahul. 0,2,3,8,
10, 12, 14., 15 :).. Sorry for unnecessarily flooding your mail
accounts. Please ignore previous post
thanks,
ankit!!
On Thu, Mar 3, 2011 at 8:15 PM, rajul jain rajuljain...@gmail.com wrote:
i think he is wrong bcoz this
@kartheek, thanks for ur input!! Certainly, ur soln is fine but only
will cater when array is 1...n but what if it ranges for 0...n-1. The
algo given by dhritiman fits in all the scenario. but ofcourse for
given question ( 1 to 100) your mathematical approach is good. :)...
Cheers,
Ankit Sinha
;
i++;
}
else
{
t= a[i];
a[i] = a[a[i]];
a[t] = t;
}
}
printf (\nmissing element is [%d], pos);
Cheers,
Ankit Sinha
On Thu, Sep 2, 2010
13 matches
Mail list logo