If memory constraint is not there than we can Hash and check in O(n) . But if memory are there then sorting looks to be the only alternative O(nlogn). Is there a O(n) solution?
On May 26, 12:38 am, Amir hossein Shahriari <amir.hossein.shahri...@gmail.com> wrote: > 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 the values) space > > On Tue, May 25, 2010 at 5:20 PM, Raj N <rajn...@gmail.com> wrote: > > 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, send email to algoge...@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. -- 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 this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.