36

GitHub - doganoo/PHPAlgorithms: A collection of common algorithms implemented in...

 4 years ago
source link: https://github.com/doganoo/PHPAlgorithms
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

PHPAlgorithms

68747470733a2f2f7777772e646f67616e2d756361722e64652f77702d636f6e74656e742f75706c6f6164732f323031382f30392f504850416c676f726974686d732e706e67

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

The library is in a beta state. Missing something? Create a pull request!

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.

Maintainer/Creator

Doğan Uçar (@doganoo)

License

MIT


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK