The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

  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);  
  

DESCRIPTION

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

SequentialSearch

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

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);

SEE ALSO

Algorithm::Sorting and Algorithm

AUTHOR

Vipin Singh, <qwer@cpan.org>

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.