comp.lang.ada
 help / color / mirror / Atom feed
From: Jano <nono@unizar.es>
Subject: Re: [OT] Hints for an algorithm - avoiding O(n^2)
Date: Sun, 14 Mar 2004 18:27:20 +0100
Date: 2004-03-14T18:27:20+01:00	[thread overview]
Message-ID: <MPG.1abeb45ed3639b339896d1@news.able.es> (raw)
In-Reply-To: 7j5s2c.32r.ln@skymaster

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 828 bytes --]

Jean-Pierre Rosen dice...
> 
> "Jano" <402450@cepsz.unizar.es> a �crit dans le message de news:5d6fdb61.0403120115.7c102e3c@posting.google.com...
> > The problem is a simple one: I'm planning to write a simulator of
> > sideral-like objects using the Newton laws (precision is not a top
> > priority). The obvious way is to compute the force interactions
> > between each pair of objects, sum them all, and iterate over... but
> > this is O(n^2). To be precise, there are n(n-1)/2 forces to be
> > computed if I'm right (n the number of objects).
> >
> If I remember my Newton laws correctly, you just need to compute the force between an object and the center of mass of all other
> objects.

I discussed this too with a colleague, but it's equivalent (apart from 
the subtleties noted by other posters) in computing time.



  parent reply	other threads:[~2004-03-14 17:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-12  9:15 [OT] Hints for an algorithm - avoiding O(n^2) Jano
2004-03-12 11:06 ` Jean-Pierre Rosen
2004-03-12 12:53   ` Stuart Palin
2004-03-12 12:55   ` Stuart Palin
2004-03-12 13:48     ` Dmitry A. Kazakov
2004-03-17  1:16       ` jtg
2004-03-12 13:30   ` Björn Persson
2004-03-12 13:42     ` James Rogers
2004-03-12 14:29     ` Robert I. Eachus
2004-03-12 23:44       ` Björn Persson
2004-03-13 15:21         ` Robert I. Eachus
2004-03-14 17:27           ` Jano
2004-03-15  5:34             ` Robert I. Eachus
2004-03-14 17:27   ` Jano [this message]
2004-03-13  0:12 ` Wes Groleau
2004-03-17  2:24 ` jtg
replies disabled

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