doganoo / phpalgorithms Goto Github PK
View Code? Open in Web Editor NEWA collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell
License: MIT License
A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell
License: MIT License
Is your feature request related to a problem? Please describe.
BinaryTree extends actually BinarySearchTree. Needs to be implemented
creating an index for HashMap class
throws an PDOException with message: You cannot serialize or unserialize PDO instances
??
As PHPAlgorithms should be type safe, we should add strict_types declaration to each file. Doing this, we need to ensure that current functionality is still given (method calls, unit tests).
It would also be glad to create unit tests for each file that does not have a test, but not a must-have yet.
The subList() method in ArrayList class does not work as expected. When slicing an array list at an index, the slicing should happen from 0 to index and from index+1 to the end.
slice properly
slices at a wrong index
$anyList = new ArrayList();
$anyList->add(1);
$anyList->add(2);
$anyList->add(3);
$anyList->add(4);
$anyList->add(5);
$upperList = $anyList->subList(0, $index);
$lowerList = $anyList->subList($index+1, $anyList->length());
$list = new ArrayList();
$list->addAll($upperList);
$list->add($value);
$list->addAll($lowerList);
print_r($list);
not tested, but in subList() method:
$array = \array_slice($this->array, $start, $end - $start -1, true);
There is a wrong comparison in Permutation.php#L54, requiring a call to permutation
for single character string permutations.
Single character string permutations should return early in Permutation.stringPermutations
.
Single character string permutations require a call to permutation
, adding a minor overhead to Permutation.stringPermutations
.
Replace (1 === $string)
with (1 === $strLen)
.
Permutation.permute
use doganoo\PHPAlgorithms\Algorithm\Various\Permutation;
$permutation = new Permutation();
$permutations = $permutation->stringPermutations("a");
I was reviewing the code out of curiosity and found the issue.
singular names in namespaces
mixed names
Is your feature request related to a problem? Please describe.
There is https://github.com/doganoo/PHPAlgorithms/blob/master/src/Datastructure/Graph/Tree/AVLTree/Node.php and https://github.com/doganoo/PHPAlgorithms/blob/master/src/Datastructure/Graph/Tree/AVLTree.php which are not implemented fully yet (buggy).
Describe the solution you'd like
implement AVLTree and write tests
Is your feature request related to a problem? Please describe.
There is https://github.com/doganoo/PHPAlgorithms/blob/master/src/Datastructure/Graph/Tree/AVLTree.php and https://github.com/doganoo/PHPAlgorithms/blob/master/src/Datastructure/Graph/Tree/RedBlackTree/Node.php which are not fully implemented yet (buggy).
Describe the solution you'd like
Implement and test (unit test)
Describe the bug
According to #22, the TimSort sorting algorithm is broken under certain circumstances.
To Reproduce
Check the PR code which tests broken code
add new unit tests and extend to cover all cases
all class methods should accept interfaces instead of classes
some classes accept implementations
reviewing the whole code
Is your feature request related to a problem? Please describe.
ConsistentHashTable is not implemented yet.
Describe the solution you'd like
Implement a consistent HashTable. Have a look here: https://medium.com/system-design-blog/consistent-hashing-b9134c8a9062#:~:text=Consistent%20Hashing%20is%20a%20distributed,without%20affecting%20the%20overall%20system.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.