If Z[] is allowed to modify then i think we can do in O(1) space // quite clear from the link I have posted above else we need O(k) space to restore Z[].
_dufus On Sep 6, 2:32 pm, ankur aggarwal <[email protected]> wrote: > @dufus > wat is your complexity ?? > > On Sat, Sep 5, 2009 at 8:17 PM, Dufus <[email protected]> wrote: > > > In that case I would sacrifice a little bit on time complexity and > > instead of storing I would recompute the values. > > > _dufus > > > On Sep 5, 5:10 pm, ankur aggarwal <[email protected]> wrote: > > > @dufus.. > > > if there is constant space requirement then ?? > > > wat will be your soln ?? > > > > On Sat, Sep 5, 2009 at 12:35 PM, Dufus <[email protected]> > > wrote: > > > > > It seems EXTRACT_MIN for Z[n^2] can be done in O(n) time. > > > >http://lyle.smu.edu/~saad/courses/cse3358/ps5/problemset5sol.pdf<http://lyle.smu.edu/%7Esaad/courses/cse3358/ps5/problemset5sol.pdf> > > <http://lyle.smu.edu/%7Esaad/courses/cse3358/ps5/problemset5sol.pdf> > > > > > Then using it we can find the kth smallest element in O(nk) time. > > > > > _dufus > > > > > On Sep 4, 10:03 pm, ankur aggarwal <[email protected]> wrote: > > > > > Find nth smallest inO(n) Given two arrays of length n in sorted > > order > > > > > X[n] & Y[n]. > > > > > Now make another array Z[n^2]={such that z belongs to X+Y}. > > > > > AS all possible sum of x+y is there in Z. You have to give the nth > > > > smallest > > > > > no of Z in O(n) time. > > > > > Space complexity : No bound on it. But try to optimize it if > > possible. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---
