The Wayback Machine - https://web.archive.org/web/20200526160219/https://github.com/doganoo/PHPAlgorithms
Skip to content
A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell
PHP
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update issue templates Oct 7, 2019
src review and reformat Dec 7, 2019
tests review and reformat Dec 7, 2019
.editorconfig review and reformat Dec 7, 2019
.gitignore updated composer.json and gitignore Mar 24, 2019
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Mar 26, 2018
CONTRIBUTING.md edit contributing.md Oct 7, 2019
ISSUE_TEMPLATE.md Create ISSUE_TEMPLATE.md Mar 26, 2018
LICENSE Initial commit Feb 18, 2018
PULL_REQUEST_TEMPLATE.md Create PULL_REQUEST_TEMPLATE.md Mar 26, 2018
README.md Update README.md Oct 9, 2019
composer.json return spl_object_hash for object keys Oct 7, 2019
composer.lock AVLTree (incomplete, unfinished) May 23, 2019
phpunit.xml initial commit Feb 18, 2018
travis.yml added travis.yml and composer.json improvements Dec 6, 2018

README.md

PHPAlgorithms

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

You can find the package on Packagist: https://packagist.org/packages/doganoo/php-algorithms

Why Using PHPAlgorithms?

"Algorithms + Data Structures = Programs"

Algorithms are a part of the basic toolkit for solving problems. Data Structures organize data in an efficient way. The combination of both allow the creation of smart and efficient software.

Installation

You can install the package via composer:

composer require doganoo/php-algorithms

Usage

Here's an Binary Tree example:

use doganoo\PHPAlgorithms\Datastructure\Graph\Tree\BinaryTree;

$binaryTree = new BinaryTree();
$binaryTree->insertValue(50);
$binaryTree->insertValue(25);
$binaryTree->insertValue(75);
$binaryTree->insertValue(10);
$binaryTree->insertValue(100);

echo json_encode($binaryTree);

produces

{"nodes":{"value":50,"left":{"value":25,"left":{"value":10,"left":null,"right":null},"right":null},"right":{"value":75,"left":null,"right":{"value":100,"left":null,"right":null}}}}

Contributions

Feel free to send a pull request to add more algorithms and data structures. Please make sure that you read https://github.com/doganoo/PHPAlgorithms/wiki/Best-Practices before opening a PR. Please also consider https://github.com/doganoo/PHPAlgorithms/blob/master/CONTRIBUTING.md.

Maintainer/Creator

Doğan Uçar (@doganoo)

License

MIT

You can’t perform that action at this time.