RangeQuery version 0.01 ======================= =head1 NAME RangeQuery - retrieves the minimum/maximum value from a set within a given range. =head1 SYNOPSIS use RangeQuery; my @set = (4,2,8,6,1,2); my $range = RangeQuery->new(@set); my $min = $range->min_value(1,3); # 2 my $max = $range->max_value (4, 6); # 6 =head1 DESCRIPTION Retrieves the minimum/maximum value in a given range. The range is represented with two 1-based indexes. It takes O(n log n) to build the RangeQuery object and O(1) to retrieve a value. =head1 METHODS =head2 new Creates a new RangeQuery object. This builds the appropriate data structure in order to retrieve values efficiently. =cut =head2 max_value Retrieves the maximum value in a given range. This receives two 1-based indexes. =cut =head2 min_value Retrieves the minimum value in a given range. This receives two 1-based indexes. =cut =head1 SEE ALSO You can check a tutorial from TopCoder, L<http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=lowestCommonAncestor> =head1 AUTHOR JoE<atilde>o Carreira, E<lt>joao.carreira@ist.utl.ptE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2009 by JoE<atilde>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. =cut