comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Algorithms Homework Help?!?!
Date: Wed, 16 Jan 2013 15:43:22 -0800 (PST)
Date: 2013-01-16T15:43:22-08:00	[thread overview]
Message-ID: <660d1b25-e1ea-48c5-a37c-1682c70b7a2e@googlegroups.com> (raw)
In-Reply-To: <wcc1udkg3vf.fsf@shell01.TheWorld.com>

On Wednesday, January 16, 2013 2:27:48 PM UTC-8, Robert A Duff wrote:

> > On top of that, I don't think this homework assignment can be done
> > with an O(log N) algorithm. ...
> 
> Oh, OK.  I didn't look at it carefully.

I looked at it a bit more.  There are two variables involved: the size of the array, and the largest number in the array.  My gut feeling was that the algorithm's time shouldn't depend on the largest value in the array.  But I'm no  longer sure.  The issue boils down to this: Suppose you have an array A(1..m) of positive integers; you can define a function f(n) = floor(A(1)/n) + floor(A(2)/n) + ... + floor(A(m)/n).  This is monotonically nonincreasing.  The problem is, given some value K, to find the largest n such that f(n) >= K.  Finding the best way to solve this problem seems like an interesting problem in number theory, and I don't know how to solve it.  Given that, and since the function is nonincreasing, using a binary search to find the answer seems reasonable.  Maybe there's a better way, though.

                            -- Adam



  reply	other threads:[~2013-01-16 23:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-15 21:52 Algorithms Homework Help?!?! willmann817
2013-01-15 22:50 ` Adam Beneschan
2013-01-15 23:50   ` willmann817
2013-01-15 23:43 ` Shark8
2013-01-15 23:54 ` Jeffrey Carter
2013-01-16  0:01   ` willmann817
2013-01-16  3:54     ` willmann817
2013-01-16 19:47 ` Robert A Duff
2013-01-16 21:19   ` Adam Beneschan
2013-01-16 22:27     ` Robert A Duff
2013-01-16 23:43       ` Adam Beneschan [this message]
2013-02-07  7:06 ` ajim
2013-02-07  7:10 ` ajim
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox