RangeQuery - retrieves the minimum/maximum value from a sequence within a given range.
use RangeQuery qw(min_value max_value); my @sequence = (4,2,-8,6,-1,2); my $range = RangeQuery->new(@sequence); my $min = $range->min_value(0,2); # -8 my $max = $range->max_value (3, 5); # 6
Retrieves the minimum/maximum value from a sequence within a given range. It takes O(n log n) to build the object and O(1) to retrieve a min/max value.
Note: You should use a more naive approach with small sequences of values.
Creates a new RangeQuery object. This builds the appropriate data structure in order to retrieve values efficiently.
Retrieves the maximum value within a given range.
Retrieves the minimum value within a given range.
Write this module in C.
You can check a tutorial from TopCoder, http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=lowestCommonAncestor
João Carreira, joao.carreira@ist.utl.pt
joao.carreira@ist.utl.pt
Copyright (C) 2009 by João Carreira
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
To install RangeQuery, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RangeQuery
CPAN shell
perl -MCPAN -e shell install RangeQuery
For more information on module installation, please visit the detailed CPAN module installation guide.