PHPackages                             yousafsyed/algorithms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yousafsyed/algorithms

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yousafsyed/algorithms
=====================

Original Proposal: Using the right data structure or algorithm for the situation is an important aspect of programming. In computer science literature, many data structures and algorithms have been researched and extensively documented. However, there is still no standard library in Php implementing useful structures and algorithms like Red/Black Trees, tries, different sorting algorithms, etc. This project will create such a library with documentation on when to use a particular structure/algorithm. It will also come with a benchmark suite to compare performance in different situations.

v1.0(10y ago)1191MITPHP

Since Jan 3Pushed 8y ago2 watchersCompare

[ Source](https://github.com/yousafsyed/algorithms)[ Packagist](https://packagist.org/packages/yousafsyed/algorithms)[ RSS](/packages/yousafsyed-algorithms/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

algorithms
==========

[](#algorithms)

---

DESCRIPTION:
------------

[](#description)

Written by [Yousaf Syed](http://linkedin.com/in/yousafsyed)

Original Proposal: Using the right data structure or algorithm for the situation is an important aspect of programming. In computer science literature, many data structures and algorithms have been researched and extensively documented. However, there is still no standard library in Php implementing useful structures and algorithms like Red/Black Trees, tries, different sorting algorithms, etc. This project will create such a library with documentation on when to use a particular structure/algorithm. It will also come with a benchmark suite to compare performance in different situations.

Install via composer
--------------------

[](#install-via-composer)

```
 composer require yousafsyed/algorithms

```

Usage
-----

[](#usage)

```
        require "./vendor/autoload.php";
		$x = 4;
		$list = array(5,2,3,4,1);
	//Sort Algorithms examples
		$list = Algorithms\Sort::insertion_sort($list);
		$list = Algorithms\Sort::insertion_sort($list);
		$list = Algorithms\Sort::comb_sort($list);
		$list = Algorithms\Sort::selection_sort($list);
		$list = Algorithms\Sort::heap_sort($list);
		$list = Algorithms\Sort::bubble_sort($list);

	// Search Algorithms examples

		echo Algorithms\Search::binary_search($list, $x);
		echo Algorithms\Search::jump_search($x, $list);
		echo Algorithms\Search::kmp_search("ABC ABCDAB ABCDABCDABDE", "ABCDABD"); // 15

	// Stack Example
		$stack = new  Containers\Stack();
		$stack->push("hellow");
		$stack->push(2);
		$stack->push(3);
		$stack->push(4);
		$stack->push(5);
		echo $stack->top();
```

FEATURES:
---------

[](#features)

Done so far:

```
	* Containers
	  - Stack			         Containers\Stack
	* Search algorithms
	  - Binary Search            Algorithms\Search::binary_search
	  - Knuth-Morris-Pratt       Algorithms\Search::kmp_search
	  - Jump Search              Algorithms\Search::jump_search
	* Sort algorithms
	  - Bubble sort              Algorithms\Sort::bubble_sort
	  - Comb sort                Algorithms\Sort::comb_sort
	  - Selection sort           Algorithms\Sort::selection_sort
	  - Heapsort                 Algorithms\Sort::heap_sort
	  - Insertion sort           Algorithms\Sort::insertion_sort

```

LICENSE:
--------

[](#license)

(The MIT License)

Algorithms and Containers project is Copyright (c) 2015 Yousaf Syed

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3785d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/407d2d8822d73af86b3d3b1ee69adfa1671e409d62aa677f1629a31bc66657b8?d=identicon)[yousafsyed](/maintainers/yousafsyed)

---

Top Contributors

[![yousafsyed](https://avatars.githubusercontent.com/u/4663209?v=4)](https://github.com/yousafsyed "yousafsyed (29 commits)")

---

Tags

stacksortalgorithmsbinary searchbubble sort

### Embed Badge

![Health badge](/badges/yousafsyed-algorithms/health.svg)

```
[![Health](https://phpackages.com/badges/yousafsyed-algorithms/health.svg)](https://phpackages.com/packages/yousafsyed-algorithms)
```

###  Alternatives

[kyslik/column-sortable

Package for handling column sorting in Laravel 6.x

6485.6M21](/packages/kyslik-column-sortable)[mottie/tablesorter

tablesorter (FORK) is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.

2.6k223.5k](/packages/mottie-tablesorter)[icecave/parity

A customizable deep comparison library.

516.8M10](/packages/icecave-parity)[symbiote/silverstripe-gridfieldextensions

A collection of useful grid field components

971.8M235](/packages/symbiote-silverstripe-gridfieldextensions)[undefinedoffset/sortablegridfield

Adds drag and drop functionality to Silverstripe's GridField

941.2M50](/packages/undefinedoffset-sortablegridfield)[doganoo/php-algorithms

A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell

9485.4k7](/packages/doganoo-php-algorithms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
