NAME

Algorithms::Searching - Provide Sequential Search & Binary Search methods.

SYNOPSIS

use Algorithms::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);

#it will return 1 if found, else -1
my $return=BinarySearch(\@list, $key);  

DESCRIPTION In this module, there are two very general searching algorithms(Sequential Search & Binary Search) written for Perl.

SequentialSearch

The subroutinne 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);
BinarySearch

The subroutine performs the Binary search method on the list which may contain number or/and characters. In return it gives 1 if found else -1.

my $return=BinrarySearch(\@array, $key);

Here, function returns 1 on success instead of index, because binary search can be performed on sorted array only. Therefore, before operation starts, BinarySearch() function sorts the array using Quick Sort algorithm.

SEE ALSO

Algorithms::Sorting and Algorithms

AUTHOR

Vipin Singh, <vipinsingh211@gmail.com>

COPYRIGHT AND LICENSE

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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 125:

You forgot a '=back' before '=head1'