I agree time should be O(kn)

On Jan 26, 9:55 pm, Sharath Channahalli
<sharath.channaha...@gmail.com> wrote:
> a) Find the median - O(n)
> b) remove the element and again find the median
> c) conitnue b until you get k-1 elements
>
> time complexity - kO(n)
>
> On Wed, Jan 26, 2011 at 9:55 PM, ritu <ritugarg.c...@gmail.com> wrote:
>
> > solution is nice!!but How to keep track of k closet numbers?
>
> > On Jan 23, 9:22 pm, ritesh <riteshcseit...@gmail.com> wrote:
> > > 1.) find x= median in o(n)
> > > 2.) subtract x from each number of the array
> > > 3.) find the k smallest number using o(n) algrithm
>
> > > On Jan 21, 4:04 am, snehal jain <learner....@gmail.com> wrote:
>
> > > > Given an unsorted array A of n distinct numbers and an integer k where
> > > > 1 <= k <= n, design an algorithm that finds the k numbers in A that
> > > > are closest in value to the median of A in O(n) time.
>
> > --
> > 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 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 algogeeks@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.

Reply via email to