Algorithm::Searching - Provide Sequential Search & Binary Search methods.
use Algorithm::Searching; my @list=(1, "hello", 123, "abc"); my $key="abc"; #it will return index of the key if found, else -1 my $index=SequentialSearch(\@list, $key); use Algorithm::Sorting; QuickSort(\@list); #for binary search array must be sorted #it will return index of key if found, else -1 my $return=BinarySearch(\@list, $key);
In this module, there are two very general searching Algorithms(Sequential Search & Binary Search) written for Perl.
The subroutine performs sequential search on the list which may contain number or/and characters. In return gives index of the item searching for if found, else -1.
my $index=SequentialSearch(\@array, $key);
The subroutine performs the Binary search method on the list which may contain number or/and characters. In return it gives index of key if found, else -1.
my $return=BinarySearch(\@array, $key);
Algorithm::Sorting and Algorithm
Vipin Singh, <qwer@cpan.org>
Copyright (C) 2013 by Vipin Singh
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.3 or, at your option, any later version of Perl 5 you may have available.
To install Algorithm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Algorithm
CPAN shell
perl -MCPAN -e shell install Algorithm
For more information on module installation, please visit the detailed CPAN module installation guide.