Re: [algogeeks] most efficient way to calculate mode in an array of numbers

2010-05-25 Thread Amir hossein Shahriari
since we have to visit each value at least once we have to do at least O(n) steps so there cant be a solution in time less than o(n) but if the range of the values is limited we can use another array to count the number of occurrences of each value and the complexity would be: o(n) time o(max of th

Re: [algogeeks] Re: another google telephone interview question

2010-05-25 Thread sharad kumar
how about using binary index tree?? On Tue, May 25, 2010 at 5:41 PM, liu yan wrote: > I think you don't need to use the median number as pivot. As long as you > use different number to do partition, after log(k) times recursive, the N > element will be sorted. > > On Sun, May 23, 2010 at 3:17 PM

Re: [algogeeks] Re: another google telephone interview question

2010-05-25 Thread liu yan
I think you don't need to use the median number as pivot. As long as you use different number to do partition, after log(k) times recursive, the N element will be sorted. On Sun, May 23, 2010 at 3:17 PM, Jagadish M wrote: > > Further to my previous post, one question. > > Can the median be found

[algogeeks] most efficient way to calculate mode in an array of numbers

2010-05-25 Thread Raj N
Hi, Can anyone tell me what is the most efficient algo to find the mode. Is it sorting and the then finding the max occurrence or can it be done in time less than O(n) ? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, s

Re: [algogeeks] templates overloading

2010-05-25 Thread Anil C R
let's break up that line you have in the end: int(*f)(char) = (int(*)(char))foo ; f('a') ; it becomes clear that f has a return type of int. So the ambiguity is resolved... Anil On Tue, May 25, 2010 at 2:25 PM, Anil C R wrote: > > Out of curiosity why would you do something like this? > Anil >

Re: [algogeeks] templates overloading

2010-05-25 Thread Anil C R
Out of curiosity why would you do something like this? Anil On Tue, May 25, 2010 at 12:45 PM, Modeling Expert < cs.modelingexp...@gmail.com> wrote: > If we have templatized functions , return type becomes part of > function signature ( which is not the case when we have normal non- > templatized

Re: [algogeeks] Starting Out

2010-05-25 Thread jayapriya surendran
@abhijit : thanks a lot. @sharad kumar : no MIT 2007 batch.. -- Thanks and Regards Jayapriya Surendran -- 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. To unsubscribe from th

[algogeeks] templates overloading

2010-05-25 Thread Modeling Expert
If we have templatized functions , return type becomes part of function signature ( which is not the case when we have normal non- templatized functions ) , So we can have two functions like these who differ only in return type template int foo(T) { cout << " this " ; } template bool foo(T) { cou