🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java
Article #429

Re: Finding 2 biggest numbers in a row

#429
From: Bart Vandewoestyne
Date: Tue, 14 Nov 2000 23:38
43 lines
2865 bytes
Andy Zaidman wrote:
>
> If you definitly wanted to work recursively...

Yes, I do.

> Try the same algo, but return
> only the biggest value and then reapply the algo to the same list, but with
> the biggest value removed...

Hmm... that is not exactly what I want to do...
The point in my algo is that if I have 4 values, say p1>p2 (found from left
side) and q1>q2 (found from right side), then i can find the two biggest numbers
from (left+right) side by:

if (p1>q1) then {
	p1 is biggest in (left+right);
	if (p2>q1) then p2 is second_biggest else q1 is second_biggest
}
else {
	q1 is biggest;
	if (q2>p1) then q2 is second_biggest else p1 is second_biggest
}

This will always result in a maximum of 2 comparisons.

> Otherwise, just plainly run through the entire
> list and keep the 2 biggest values in 2 variables...

That is not what I want to do.  I want to implement the recursive algorithm.

I will try to check my program and correct it, but in the meanwhile, I
appriciate some more feedback on what exactly I should change...

Thanx,
mc303

-- 
Ing. Bart Vandewoestyne			  Bart.Vandewoestyne@skynet.be
Hugo Verrieststraat 48			       GSM: +32 (0)478 397 697
B-8550 Zwevegem					 http://hello.to/MC303
----------------------------------------------------------------------
"Any fool can know, the point is to understand." - Albert Einstein
Technical Details
Message-ID: <3A11CCFF.A6526AE9@skynet.be>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!not-for-mail
References: <3A11B99A.2BB2E1E7@skynet.be> <8usf9t$fod$1@news1.skynet.be>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10a146,470c011dba4db9c3
X-Google-Attributes: gid10a146,public
X-Google-Thread: fcea4,470c011dba4db9c3
X-Google-Attributes: gidfcea4,public
X-Google-Thread: f5d71,470c011dba4db9c3
X-Google-Attributes: gidf5d71,public
X-Google-Thread: 113ae9,470c011dba4db9c3
X-Google-Attributes: gid113ae9,public
X-Google-ArrivalTime: 2000-11-14 15:35:56 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!not-for-mail
From: Bart Vandewoestyne <Bart.Vandewoestyne@skynet.be>
Newsgroups: comp.lang.java,comp.lang.java.help,comp.lang.java.programmer,be.comp.programming
Subject: Re: Finding 2 biggest numbers in a row
Date: Wed, 15 Nov 2000 00:38:39 +0100
Organization: MyHome
Lines: 43
Message-ID: <3A11CCFF.A6526AE9@skynet.be>
References: <3A11B99A.2BB2E1E7@skynet.be> <8usf9t$fod$1@news1.skynet.be>
NNTP-Posting-Host: marvin.kulnet.kuleuven.ac.be
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: naxos.belnet.be 974244956 28877 134.58.127.3 (14 Nov 2000 23:35:56 GMT)
X-Complaints-To: abuse@belnet.be
NNTP-Posting-Date: Tue, 14 Nov 2000 23:35:56 +0000 (UTC)
X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.4.0-test10 i686)
X-Accept-Language: nl-BE, nl, en, de
Cache-Post-Path: marvin!unknown@kn-10-0-53-046.kotnet.kuleuven.ac.be
X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/)