PHP Classes

Binary search: Search for data in files using binary search

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 59%Total: 2,886 All time: 1,301 This week: 455Up
Version License PHP version Categories
binary_search 1.0Artistic License5.0Algorithms, PHP 5, Files and Folders, S...
Description 

Author

This class can be used to quickly search for sorted data in large files using the binary search algorithm.

It can search for a given identifier in a file that has lines that contain only the identifier and a value separated by a tab character.

The class uses the binary search algorithm to quickly narrow the search for a given identifier even when the files are very large.

Innovation Award
PHP Programming Innovation award winner
September 2008
Winner


Prize: One book of choice by Apress
Sometimes it is necessary to search a large amount of data for given information.

One way to reduce the time that is necessary to search the data is to store it in a file sorted by the key search values. Then we can used the binary search algorithm to quickly find the data in the file without having to load it all at once in memory.

This class implements the binary search algorithm in pure PHP code.

Manuel Lemos
Picture of Alex Fourth
Name: Alex Fourth <contact>
Classes: 1 package by
Country: Ukraine Ukraine
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

  Files folder image Files  
File Role Description
Plain text file binary_search.class.php Class Does all work
Accessible without login Plain text file test.php Example Example how to use the class
Accessible without login Plain text file data.csv Data Example data to search in

 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,886
This week:0
All time:1,301
This week:455Up
User Ratings User Comments (1)
 All time
Utility:85%StarStarStarStarStar
Consistency:82%StarStarStarStarStar
Documentation:-
Examples:89%StarStarStarStarStar
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1243
 
Nice work and very well coded.
15 years ago (David Ferreira)
70%StarStarStarStar