This problem has been discussed before @
http://groups.google.co.in/group/algogeeks/browse_thread/thread/9c1e1aa8cf1ed437/d451cd9468d985f7
I believe, the problem can't be solved in O(n) but only in O(nlog n).
@Divya: Are you sure the interviewer explicitly asked for an O(n) time
algorithm?
On
.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Shishir Mittal
Ph: +91 9936 180 121
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com
(log n) - 2 from (n-1 + n-2) comparisons that would be required in case
of a naive algorithm where one first finds the maximum and then finds the
maximum of the remaining elements of the array.
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You
anyone give me algorithm for finding the second largest element in
array using tournament method requiring n+logn-2 compariso
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
doesn't provide correct results. Try to dry run
the code for some more test cases like ( 4 3 2 1) , ( 3 1 3 2).
Refer Introduction to Algorithms, II Ed. (Cormen) Exercise 9.1-1 and the
preceding discussion for more info regarding tournament principle.
--
Shishir Mittal
Ph: +91 9936 180 121
and then highest among the
number which get defeated during tournament.
(details in corment).
Can anyone do code implemenation for this one.
Thanks
Nagendra
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because
the highest number and then highest among the
number which get defeated during tournament.
(details in corment).
Can anyone do code implemenation for this one.
Thanks
Nagendra
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received
;
int ar[n];
for(i=0;in;i++)
cinar[i];
res=sec_largest(ar,n);
coutsecond largest number=resendl;
}
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you
.
What algorithm can be used to decide how to break up the entered
amount?
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
]+1.
In the proposed algorithm, searching for minimum element is done using min
heap.
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
A correction in the proposed algorithm.
On Tue, Sep 15, 2009 at 1:08 PM, Shishir Mittal 1987.shis...@gmail.comwrote:
*Algorithm.*
1) Corresponding to each element in X, create a node with 2 values, to be
compared indexed of Y, and the corresponding sum.
NODE[i] = {yIndex, sum = X[i
smallest
no of Z in O(n) time.
Space complexity : No bound on it. But try to optimize it if possible.
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group
0
--
hence 43 + 14 = 111001 = 57
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks
is
minimum.
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from
understand
cann u give an example..
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks
of.
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email
wrote:
Given a set S of n distinct numbers and a positive integer k = n.
Determine the k numbers in S that are closest to the median of S.
Find an O(n) algorithm
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message
--
Shishir Mittal
Ph: +91 9936 180 121
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email
There were some errors in my solution.
On Thu, Aug 27, 2009 at 6:10 PM, Shishir Mittal 1987.shis...@gmail.comwrote:
Its a bit similar to finding the rank of the word COMPUTER in the
dictionary among the words formed from C,O,M,P,U,T,E,R.
Find maximum r such that (k+r)C(r) n
19 matches
Mail list logo