🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: sci.math.num-analysis
Article #84

Re: An efficient way of finding the the delta of two numbers

#84
From: Anthony Bloesch
Date: Wed, 22 Jul 1992 00:09
20 lines
1350 bytes
In <BrpsJC.5HE@cs.columbia.edu> amir@cs.columbia.edu (Amiran Eliashvili) writes:


>Hi all:

>	I am trying to come up with an efficient way (fewest number of
>iteration ) to find in a list of numbers (not sorted) two numbers
>whose delta (x - y) is the least. So far I could see O(n^2) and
>possibly n*log(n). Are there any kind souls out there that know of a
>better methods that will improve on the above number of iterations?

Interesting problem.  I would guess the best way boils down to sorting
the list and then running  through  it looking for  the number that is
closest to it's successor.  Now this  can be done in  O(n log  n) time
with no real memory overhead by quicksort.  But since they are numbers
we can do it in O(n) time with a radix or distribution sort.  Thus you
are looking at O(n) time.  It seems to me that you will not  do better
than this.

                                       Anthony
Technical Details
Message-ID: <9480@uqcspe.cs.uq.oz.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!uqcspe!cs.uq.oz.au!anthonyb
References: <BrpsJC.5HE@cs.columbia.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!uqcspe!cs.uq.oz.au!anthonyb
From: anthonyb@cs.uq.oz.au (Anthony Bloesch)
Newsgroups: sci.math.num-analysis
Subject: Re: An efficient way of finding the the delta of two numbers
Message-ID: <9480@uqcspe.cs.uq.oz.au>
Date: 22 Jul 92 00:09:45 GMT
References: <BrpsJC.5HE@cs.columbia.edu>
Sender: news@cs.uq.oz.au
Reply-To: anthonyb@cs.uq.oz.au
Lines: 20