Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: getting elements from an array based on a value not in the array

by Ieronim (Friar)
on Aug 11, 2006 at 19:42 UTC ( [id://566926]=note: print w/replies, xml ) Need Help??


in reply to getting elements from an array based on a value not in the array

if lima1 is right, you need to specify what you want to get if $target is in the @test and if $size exceeds the boundaries of the array. Next problem is processing duplicates.

I.e., what do you want to get if $target = 5 or if $target = 0?

After you define this, all you need is to implement binary search like BrowserUK's.

NOTE: his solution does not handle the case when $target is outside the array at all.


     s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://566926]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 02:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found